22

Installation-file-cleaning is currently only available in the licensed edition of Chocolatey ($96 a year) and the developers seemingly have no plans to offer cache-cleaning support for the free version.

The package installation files can easily take gigabytes of storage space and to my knowledge they only increase in size as the user updates packages and installs new software, with only your hard drive capacity as the upper limit.

I don't know if Chocolatey stores cache in one central location — something is saved to ~\AppData\Local\Temp but the majority is located in the lib* folders in ~\ProgramData\chocolatey. Also the log files in the logs folder total to over 100 MB on my system. Is there any way to fully clear Chocolatey cache without manually deleting directories?

30

You may use for cleaning the cache the unofficial but approved package of choco-cleaner.

The installed package creates a Windows Scheduled Task to run Choco-Cleaner.ps1 every Sunday at 11:00 PM.

To install, run the following:

choco install choco-cleaner

To upgrade (unofficial) Choco Cleaner (Script + Task), run the following:

choco upgrade choco-cleaner

You may also manually run this task immediately in one of the following ways from the documentation:

  • Command Prompt:

    \ProgramData\chocolatey\lib\choco-cleaner\tools\Choco-Cleaner-manual.bat
    
  • PowerShell:

    Set-ExecutionPolicy -ExecutionPolicy Unrestricted
    \ProgramData\chocolatey\bin\Choco-Cleaner.ps1
    
  • Windows Start Menu: If you have choco-shortcuts-winconfig installed you'll find it with the rest of the Chocolatey Shortcuts.

4
  • I had to change PowerShell execution policy to run the script, may be worthwhile to add this information to the answer. – user598527 Oct 31 '18 at 19:34
  • Good idea. Done. – harrymc Oct 31 '18 at 19:37
  • Since the latest release, the PowerShell script seem to be here: C:\tools\BCURRAN3\choco-cleaner.ps1 and the wrapper batch file is here: C:\ProgramData\chocolatey\bin\choco-cleaner.bat Not sure why this change has happened. – Gokul NC Apr 12 '20 at 7:59
  • @GokulNC That is the location of choco shims, from chocolatey.org/docs/features-shim#usage: "Chocolatey ensures the folder "$($env:ChocolateyInstall)\bin" in the PATH environment variable, allowing you to put tools on the PATH without cluttering up the PATH." – Otzen Sep 7 '20 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.