-
Notifications
You must be signed in to change notification settings - Fork 342
install.ps1 sets ChocolateyInstall environment in user contest #283
Comments
We have an open PR to evaluate doing this at system - #135 |
To summarize, the problem is that setting a system var requires admin rights, which are not available when the user installs chocolatey without elevating the shell which is used to install it. Have I got that right? |
@DavidS you have that correct. And the secondary issue is that the user may not have admin privileges on their machine. |
Any updates on this? For our use case it's odd, b/c Chocolatey is designed to be installed once per machine (based on default of C:\Chocolatey instead of local apps), but there is no way to detect if it installed since this variable is set as a user variable. |
I have my own script to make the setting in the System env. However I also use 'choco /?' to determine if it's installed. (preferred to use something like 'choco -version' but that does not quite do same thing) choco /? will return %errorlevel% of 0 if it found the command, and 9009 otherwise but you can just check for the success/fail like this: choco /? || install-choco where "install-choco" is the big powershell string you can paste in to install or maybe some other way you want to install. |
Thanks; any suggestion on how to reliably detect the installation directory of chocoaltey? That’s what we’re mostly looking to do… |
YES!! and I just found it by searching for "Windows version of which" C:\software>where choco where /? for more help. |
I had considered that... but that basically just searches PATH (a user variable), so this only works for the user that installed chocolatey. |
Yes, that is one way to know if chocolatey is installed. We are looking to go to system path for installs so it is available for all. |
oh yeah. So as mentioned, when I install it, I wrapped it in a script that calls a .VBS script to put the path in the System env: ENV_VARIABLE = WScript.Arguments.Item(0) Use it like this: which would set whatever env var to the value you specify in the System section. And then can use this .BAT logic to only do that if it's not already there in the current session: To use that "function" it would look like this: |
And regarding testing if it's installed... forgot that you don't need the /? this works just as well: choco || install-choco |
And finally... :) You can use this to actually FIND it installed and in what dir: C:>dir /s/b choco.bat unless you also need to search other drive letters. |
Hi,
when installing chocolatey via the install.ps1 from http://chocolatey.org/install.ps1, the ChocolateyInstall env variable is set in the user context. This leads to the chocolatey puppet provider not working as puppet runs as "Local System" and not the user doing the first deployment.
Thanks for this great tool, David
The text was updated successfully, but these errors were encountered: