Search code examples
powershellchocolatey

How can I change the "Temp" directory that Chocolatey uses when Installing itself or packages?


I am trying to install Chocolately on our servers at work, but I have a problem due certain McAfee rules that prevent us from unzipping or running an executable's from the Temp directory (From reviewing the Chocolately code, the $env:TEMP variable is used in a few places). I have tried to update the $env:TEMP variable myself, but there are policies that set it back immediately. I have even tried to update the $env:TEMP variable and install Chocolatey in the same powershell session, but it seems to set it back again.

Does anyone have any other suggestions / ideas? Any help is much appreciated. Thank you


Solution

  • In Chocolatey this is controlled by CacheLocation - choco config get cachelocation (if empty, it uses $env:TEMP, otherwise it uses the value it is set to). This was added in 0.9.9. The specific commit to add cacheLocation was dc47d644.

    For the installation of Chocolatey itself, you can adjust this simply by setting $env:TEMP='c:\some\location prior to running the installation script.

    Original Accepted Answer:

    Wow, this is interesting. I'm guessing we need to be able to make it settable. That's pretty insane that something would limit the use of the TEMP folder like that, but I can definitely see why someone would want to do that.

    What I think I would do is to just go into the scripts for chocolatey and change everything not to use temp folder. There are probably 2 or 3 places where this is. You will need to out of band the install for chocolatey though as it attempts to do the same. Use nuget to install chocolatey, and then open a powershell session and run that installer - Check on the wiki for specific instructions on that https://github.com/chocolatey/chocolatey/wiki/Installation#wiki-nugetexe--powershell-method