-
Notifications
You must be signed in to change notification settings - Fork 904
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
Refreshenv not working with p4 #1600
Comments
did you notice the message that says: ^^ Would be the cause of why it doesn't work for you. Most likely you don't have the necessary alias in your powershell profile, which causes it to use the wrong If you add the following to your powershell profile, it should then work for you # Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
} You can add this without editing the file manually by running: Add-Content -Path "$profile" -Value @'
# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
Import-Module "$ChocolateyProfile"
}
'@ |
Actually your script seems to work sometimes??? Is very strange, sometimes the env vars don't seem to actually update and other times they do.... |
meh, it seems to at least work on the first try via powershell this way. Doesn't really need to be mroe reliable then that for this use and I don't need to use cmd /c anyway |
Any changes to path or other environment variables won't come back up to the parent process and the parent process passes it's environment variables to a subprocess. So powershell.exe ->
HTH explain the craziness here. So any call to refresh environment variables must be run in process. |
And the above is all Windows - refreshenv is how we have something that deals with that limitation. But it's a straight call, no shelling out to a subprocess (aka |
I was suspicious the subprocess thing might be the case which is why I tried to do both commands in the same call, but that didn't work either |
Use `Update-SessionEnvironment` to refresh the current shell's environment. The `refreshenv` command used earlier doesn't seem to do the trick based on the `cmd.exe` line seen in the [logs](https://github.com/jmcker/ChocolateyPackages/runs/2392035005?check_suite_focus=true#step:2:916) and [this issue](chocolatey/choco#1600)
Official explanation has been added to Troubleshooting - https://docs.chocolatey.org/en-us/troubleshooting#refreshenv-has-no-effect |
What You Are Seeing?
I'm using chocolatey to install the p4 cmd line tools. After the install it talks about running refreshenv to load the PATH changes but even after I run refreshenv neither powershell or cmd.exe recognize p4
What is Expected?
For p4 to be a recognized cmd after refreshenv is run.
How Did You Get This To Happen? (Steps to Reproduce)
I ran "choco install p4 --ignore-checksums"
(the checksums are wrong currently cause perforce did an update this morning)
I then ran "refreshenv"
I then tried both "p4 set" and "cmd /c 'p4 set'" and neither could find p4 as a cmd
when I opened a fresh powershell window both "p4 set" and "cmd /c 'p4 set'" worked just fine
Output Log
I'm attaching the log info pulled from the chocolatey log file, it's only the p4 install cause refreshenv doesn't seem to log anything :/ I'm also attaching a screen shot of my powershell window
I'm on an aws instance running Windows Server 2016 version 10.0.14393.0, my powershell version is 5.1.14393.2248 and my chocolatey is version 0.10.11.0
Please let me know if you need any other info.
choco_log.txt
The text was updated successfully, but these errors were encountered: