-
Notifications
You must be signed in to change notification settings - Fork 342
Chocolatey install did not configure $env:Path #140
Comments
This only happens on the session (or existing sessions) that you do the install from, correct? |
Once you close and open a new powershell session, this works appropriately, correct? |
Or you actually checked the environment path and it wasn't there and then added that to your session? |
@ferventcoder the environment variable for chocolatey was not there, i had to manually add it with C:\projects> $env:Path += ";C:\Chocolatey\bin;" |
Last time I checked that only updates your current session, not the path variables stored on your machine. |
@ferventcoder are you refering to the chocolatey install or env:Path? env:Path is most certainly system Environment Path variable, i also used this same command to setup environment path for python after it didn't do it either. |
I'm referring to opening control panel, system, advanced, variables and the PATH variables in there. There is one for user and one for system. Just b/c it doesn't end up in your current session (of powershell or cmd) doesn't mean it didn't get added to the actual path. Here's an experiment: open the system stuff in control panel and then go back to your powershell session and add c:\bob; to the path the same way you did in powershell. Now look in the actual path to see if it got added. Both places (user and system). Now close and reopen powershell. Write-host your path. Is c:\bob still there? |
The problem here is that Powershell does not "recapture" the environment variables once a session has been started. So PATH could be modified, after running an installer, but Chocolatey cannot gain access to these without using the .NET System EnvironmentVariable APIs or manually accessing the real location in the registry -- i.e.. (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path).Path IMHO, what needs to be done is that the environment needs to be refreshed after a given installer wraps up. I would do a pull req, but not sure if this is the best / only spot where an installer finishes up. To recapture any changes made to PATH by external processes. $Env:PATH = (@(,[Environment]::GetEnvironmentVariable('PATH', 'Machine') -s
plit ';') + @([Environment]::GetEnvironmentVariable('PATH', 'User') -split ';') | Select -Unique) -join ';' BTW - I was just coming to submit this issue based on Yeoman install failing on a machine without Ruby or Node initially installed. |
I think I like that better dropped into a new issue - your fix... please submit as an enhancement. |
Just FYI - choco 0.9.10 supports this now without closing and reopening your shell - chocolatey/choco#664 |
After running choco install cmake.install --installargs 'ADD_CMAKE_TO_PATH=""System""'
refreshenv I still have to close out the Admin PowerShell window before Same thing happens with:
|
@acgetchell Can you tell me the output of calling refreshenv? Does it say "Refreshing for cmd.exe" or does it say for powershell.exe? If it says the former, it means you do not have the PowerShell profile installed - which provides this and tab completion. See https://chocolatey.org/docs/troubleshooting#why-does-choco-intab-not-work-for-me on how to remedy this so that when you call refreshenv, it is the PowerShell version that is being called and not refreshenv.bat. |
Please see chocolatey/choco#991 and chocolatey/choco#894 to get a better understanding of why this isn't set by default on install. |
I also filed chocolatey/choco#1392 |
@acgetchell Looks like an artifact of already having that in the PATH when you ran it the second time. It doesn't show that environment variables like PATH were updated in the output and I don't see a call to refreshenv here. |
After installing Chocolatey by executing the @PowerShell.... command on the chocolatey.org homepage, my environment path was not updated.
After the install:
C:\projects> Get-Command chocolatey
Get-Command : The term 'chocolatey' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if
a path was included, verify that the path is correct and try again.
With my hacking:
C:\projects> $env:Path += ";C:\Chocolatey\bin;"
C:\projects> Get-Command chocolatey
CommandType Name Definition
Application chocolatey.bat C:\Chocolatey\bin\chocolatey.bat
Windows 7 Pro x64
Powershell policy unrestricted
UAC disabled
The text was updated successfully, but these errors were encountered: