-
Notifications
You must be signed in to change notification settings - Fork 903
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
Installing chocolatey removes $env:PSModulePath changes for current powershell session #295
Comments
To be clear this is only during the install. Where are the other values resolved from? |
Yes, I've only noticed this during install. Not sure where those other values are coming from. https://msdn.microsoft.com/en-us/library/dd878326%28v=vs.85%29.aspx suggests the Documents path is a default ($home\Documents\WindowsPowerShell\Modules) - perhaps it's being added by Powershell itself - but doesn't explain the Program Files path. I'm still hunting that down - will let you know if/when I find it. But either way - shouldn't in-process changes to $env:PSModulePath be respected, wherever they've come from? If they were set by the script that's installing chocolatey, then you wouldn't be able to resolve them from anywhere other than $env:PSModulePath. |
The problem is that Update-Session is somewhat naive, it only loads the values from the registry. |
This is not a duplicate, it's only related. |
To be clear it's only messing up changes in the current powershell session. Once you close and reopen powershell, everything is back to normal. |
When running Chocolatey install / refreshenv, Chocolatey should not replace PSModulePath. It should keep the current value.
Hey guys just throwing a comment in here since I've been following this related to #129. Wouldn't it make sense that if any packages you install make persistent changes to the system or user PSMODULEPATH, at the conclusion of those packages, running refreshenv should cause PSMODULEPATH to be whatever is in the user variable (from the registry) and if a user level variable is not defined, it would be whatever is the system variable in the registry? This is what the command prompt normally does from testing I've done. Curious what others think. Have run some of this by rob but I don't want to suggest he make a change that conflicts with what the rest of the community would expect. Thanks! |
When installing in a powershell process with something like:
After the install, $env:PSModulePath has reverted to the Machine level environment variable.
This is causing problems for me as the Machine level variable only has:
But as part of establishing a powershell session, $env:PSModulePath looks like:
After installing chocolatey, it reverts to:
And the absence of the Documents and Program Files paths causes problems for other things I'm trying to do in the same script.
Seems likely this is being done by Update-SessionEnvironment. The need for Update-SessionEnvironment is clear, but could it possible merge with the existing $env:PSModulePath rather than assuming that the process has not yet modified it?
The text was updated successfully, but these errors were encountered: