Issue: install instruction doesn't work
gitcnd opened this issue · 6 comments
Issue Description
I did this:-
PowerShell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; [Net.ServicePointManager]::SecurityProtocol = 'Tls12'; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex"
I see this afterwards:
PS C:\Users\cnd> gsudo powercfg /requests
gsudo: The term 'gsudo' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Steps to Reproduce
- install using above
- notice that it didn't do the install properly - seems to have placed it someplace other than in the path, which is at odds with the instructions which clearly said it should be in the path.
- installer should put this in the place it belongs, not someplace else and then expect us to manually change things to make it work
Context:
- Windows version: 11
- gsudo version: latest from today
I reinstalled, this time trying the following:
PS C:\Users\cnd> Write-Output "`nImport-Module 'C:\Program Files (x86)\gsudo\gsudoModule.psd1'" | Add-Content $PROFILE
Add-Content: Could not find a part of the path 'C:\Users\cnd\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'.
PS C:\Users\cnd> echo $PROFILE
C:\Users\cnd\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Users\cnd> dir C:\Users\cnd\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
Get-ChildItem: Cannot find path 'C:\Users\cnd\Documents\PowerShell\Microsoft.PowerShell_profile.ps1' because it does not exist.
PS C:\Users\cnd>
looks like another edge-case not considered?
It seems there are a couple issues.
For the $env:PATH
issue, it appears you could resolve by adding ${Env:ProgramFiles(x86)}\gsudo
to your $env:PATH
. For the greater scope of the issue, the installer script should probably update the $env:PATH
.
This bit of code below
Line 40 in 986ad43
should be:
Write-Output "`nImport-Module 'C:\Program Files (x86)\gsudo\gsudoModule.psd1'" | Add-Content $PROFILE -Force
This will force the creation of the $PROFILE
if it doesn't exist. A note on clarity, the above code doesn't install the binary.
On a holistic point of view... is it sustainable to install things in new places every time, and endlessly keep updating the (limited space) path to include them?
gsudo is just a couple of files - they should probably be installed someplace in an existing path (i.e. in any unlimited-space folder), instead of having their own, no ? ( you know - like how Linux works - /usr/local/bin/ )
p.s. the -Force idea also doesn't work:
PS C:\Program Files\PowerShell\7> Write-Output "`nImport-Module 'C:\Program Files (x86)\gsudo\gsudoModule.psd1'" | Add-Content $PROFILE -Force
Add-Content: Could not find a part of the path 'C:\Users\cnd\Documents\PowerShell\Microsoft.PowerShell_profile.ps1'.
PS C:\Program Files\PowerShell\7> dir C:\Users\cnd\Documents\PowerShell
Get-ChildItem: Cannot find path 'C:\Users\cnd\Documents\PowerShell' because it does not exist.
PS C:\Program Files\PowerShell\7>
I agree on the holistic point. I use choco
and scoop
for this reason which I would recommend for this project. I am still meticulous when it comes to install locations and my $env:PATH
. I typically avoid installers within projects and just use the package managers which isn't to say that they shouldn't work.
To your second point, I forgot about the folder creation. Thanks for pointing that out. The below should work.
if ( -not ( Test-Path $PROFILE ) ) { New-Item $PROFILE -Force }; Write-Output "`nImport-Module 'C:\Program Files (x86)\gsudo\gsudoModule.psd1'" | Add-Content $PROFILE
gsudo: The term 'gsudo' is not recognized...
You must restart your consoles as the install instruction indicates:
Get-ChildItem: Cannot find path 'C:\Users\cnd\Documents\PowerShell\Microsoft.PowerShell_profile.ps1' because it does not exist.
Fixed.
On a holistic point of view... is it sustainable to install things in new places every time, and endlessly keep updating the (limited space) path to include them?
It may not be sustainable, but the alternatives are worse. If you are worried about your path being polluted, use Scoop.
Thanks @mattcargile for addressing the other issues!