-
Notifications
You must be signed in to change notification settings - Fork 910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible bug in Install-ChocolateyPath.ps1 #1015
Comments
Agreed. Hacktoberfest it is. |
Ok - I'll do this one too as well. |
IIRC, this entire function could use some modernization (or best practices for PowerShell added in). Splitting all values into an array at |
OK cool - that's exactly the code I had planned for uninstall, but wasn't sure how much to stick to the existing patterns. |
Is it ok just to call Update-SessionEnvironment like earlier in the same code? : https://github.com/darwinjs/choco/blob/master/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1#L76 |
Adding some more problem data here - the function does not work when the path being requested is a parent of a path that is already on the path (stumbled upon when using 'c:\users' as a test case). I believe this would be fixed by parsing the path into an array and comparing our path to each array item for an exact, case insensitive match. However, this will be more changes than the if statement. |
PR #1017 |
Another related issue with that line is that it compares what I want to add with $env:Path always expanded, which means it will always add to the Path again if I'm actually trying to add something that is not expanded (e.g. '%ProgramFiles%\example'). It seems this is already covered by the PR, but I thought it would be nice to keep it documented here (I was searching for an issue and found that this already fixes it). |
I am no longer able to reproduce this issue as of 2.3.0 with the following steps on Windows:
As such, I'll be closing this issue as resolved. |
This line checks the existing path without qualifying it for "user" or "machine"
https://github.com/darwinjs/choco/blob/master/src/chocolatey.resources/helpers/functions/Install-ChocolateyPath.ps1#L78
However, the path addition statements later in the code are structured so as to add the path only to the requested scope.
If a packager calls the function with the intent of adding to "machine", shouldn't the code add it to machine EVEN IF it already exists in user?
Paths in machine are [a] available when no one is logged in (e.g. group policy processing), [b] are available to system processes and services (that do not login as the current user) and [c] are available to all users - so it differs significantly in functionality.
It seems if line 78 also qualified the check by user or machine it would seem to properly handle situations where the path exists in user, but the intent is to make the software available to all users or the system and I think it should also accurately handle situations where the intent is to only update the user's path for them to use the software.
The text was updated successfully, but these errors were encountered: