-
Notifications
You must be signed in to change notification settings - Fork 909
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
GH-303 Install-ChocolateyPath Expands Variables in PATH, Overwriting #373
Conversation
Unfortunately due to where this is, it's not easily testable on OS X. |
$option = [Microsoft.Win32.RegistryValueOptions]::None | ||
} | ||
|
||
$value = $reg.GetValue('Path', $null, $option) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path
should be $Name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed this hasn't yet been updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mnadel Take a look here, this PR hasn't been updated.
Thanks, I suspected as much.
|
…erwriting Preexisting Variables When adding a new element to PATH, Install-ChocolateyPath reads PATH (wh ich contains expanded variables), appends the new element, and then writes the value back to PATH. This results in PATH having its variables overwritten with its values. Instead of reading $env:PATH to find the current path, read it from the registry, which will retain the PATH's original variables.
a5245bc
to
bafe091
Compare
function Get-EnvironmentVariable([string] $Name, [System.EnvironmentVariableTarget] $Scope, [bool] $PreserveVariables = $False) { | ||
if ($pathType -eq [System.EnvironmentVariableTarget]::Machine) { | ||
$reg = [Microsoft.Win32.Registry]::Machine.OpenSubKey("Environment", $true) | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not handle the third possible EnvironmentVariableTarget, Process (which has nothing to do with the registry).
Superseded by #600. |
This is untested ... thoughts on how to test this on a Mac?
Closes #303