Skip to content
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

Closed

Conversation

mnadel
Copy link
Contributor

@mnadel mnadel commented Jul 30, 2015

This is untested ... thoughts on how to test this on a Mac?

Closes #303

@ferventcoder
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path should be $Name

Copy link
Contributor Author

@mnadel mnadel Jul 30, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

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.

Copy link
Member

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.

@mnadel
Copy link
Contributor Author

mnadel commented Jul 30, 2015 via email

…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.
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 {

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).

@ferventcoder
Copy link
Member

Superseded by #600.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants