Swift Software Group

How to use a different cache directory for Chocolatey packages

About Chocolatey

In short, Chocolatey is a package manager for Windows which saves time by automating otherwise manual installation tasks. You can install Chocolatey by following the instructions on chocolatey.org.

Configure Chocolatey’s Cache Folder

For security reasons, Chocolatey installs in C:\ProgramData\chocolatey by default. See Why does Chocolatey install where it does? for more information.

Also by default, Chocolatey will download packages in C:\Users\USERNAME\AppData\Local\Temp\chocolatey which might work or not for you. If you need to use a different folder, you can set the cacheLocation key in C:\ProgramData\chocolatey\config\chocolatey.config to a folder of your choice.

For example, to use C:\ChocolateyCache as a cache folder, add <add key="cacheLocation" value="C:\ChocolateyCache" description="Cache location if not TEMP folder." /> to the chocolatey.config file like this:

<?xml version="1.0" encoding="utf-8"?>
<chocolatey xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <containsLegacyPackageInstalls>false</containsLegacyPackageInstalls>
  <commandExecutionTimeoutSeconds>0</commandExecutionTimeoutSeconds>
  <config>
    <add key="cacheLocation" value="C:/ChocolateyCache" description="Cache location if not TEMP folder." />
    <add key="containsLegacyPackageInstalls" value="true" description="Install has packages installed prior to 0.9.9 series." />
    <add key="commandExecutionTimeoutSeconds" value="2700" description="Default timeout for command execution." />
    <add key="proxy" value="" description="Explicit proxy location." />
    <add key="proxyUser" value="" description="Optional proxy user." />
    <add key="proxyPassword" value="" description="Optional proxy password. Encrypted." />
  </config>
  <sources>
    <source id="chocolatey" value="https://chocolatey.org/api/v2/" disabled="false" priority="0" />
  </sources>
  <features>
    <feature name="checksumFiles" enabled="true" setExplicitly="false" description="Checksum files when pulled in from internet (based on package)." />
    <feature name="autoUninstaller" enabled="false" setExplicitly="false" description="Uninstall from programs and features without requiring an explicit uninstall script." />
    <feature name="allowGlobalConfirmation" enabled="false" setExplicitly="false" description="Prompt for confirmation in scripts or bypass." />
    <feature name="failOnAutoUninstaller" enabled="false" setExplicitly="false" description="Fail if automatic uninstaller fails." />
  </features>
  <apiKeys />
</chocolatey>