52

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?

1 Answer 1

73

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
    C:\tools\BCURRAN3\choco-cleaner.ps1
    
  • Windows Start Menu: If you have choco-shortcuts-winconfig installed, you'll find it with the rest of the Chocolatey Shortcuts.

7
  • I had to change PowerShell execution policy to run the script, may be worthwhile to add this information to the answer.
    – user198350
    Commented Oct 31, 2018 at 19:34
  • Good idea. Done.
    – harrymc
    Commented Oct 31, 2018 at 19:37
  • 4
    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
    Commented Apr 12, 2020 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
    Commented Sep 7, 2020 at 9:02
  • I've been using chocolatey for a while... just ran this and freed up close to 5GB. This is the way.
    – m1m1k
    Commented May 11, 2022 at 14:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .