How to clear the Homebrew cache
Homebrew keeps downloaded bottles, cask installers and old versions of upgraded formulae. brew cleanup is the built-in way to clear them. Your installed apps and current versions stay.
Where it lives
brew --cache
- macOS:
~/Library/Caches/Homebrew - Linux:
~/.cache/Homebrew - Windows: Homebrew does not run natively. Under WSL it uses the Linux path.
Old versions of upgraded formulae live in the Cellar: /opt/homebrew/Cellar (Apple silicon), /usr/local/Cellar (Intel), /home/linuxbrew/.linuxbrew/Cellar (Linux).
Preview first
brew cleanup -n # dry run: lists what would be removed
Clear it
brew cleanup # old versions + stale downloads brew cleanup --prune=all # also every cached download, whatever its age
Homebrew also runs a cleanup on its own every so often after installs and upgrades, unless HOMEBREW_NO_INSTALL_CLEANUP is set.
Remove dependencies nothing needs
brew autoremove -n # preview brew autoremove
Removes formulae that were only installed as dependencies and are no longer needed.
Measure with devdisk
devdisk is a free, read-only scanner. On macOS it lists ~/Library/Caches/Homebrew under Safe to regenerate with brew cleanup --prune=all as the suggested command. It never deletes anything; it only shows sizes and writes a cleanup script you read and run yourself. On Linux, check ~/.cache/Homebrew with du -sh.
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py
Want one-click cleanup?
A planned devdisk desktop app for Mac and Windows: live treemap, cleanup that moves files to the Trash, scheduled scans. One email when it launches, with an early-supporter price. Your address is used only for that, and every email has an unsubscribe link.
FAQ
Is it safe to delete ~/Library/Caches/Homebrew?
Yes. It only holds downloads Homebrew can fetch again. brew cleanup --prune=all does the same thing more tidily.
Will brew cleanup uninstall my apps?
No. It removes old versions and cached downloads. The current version of each formula and cask stays installed.
Why is the Cellar still big?
The Cellar holds installed software. Use brew list and brew uninstall for things you no longer need, then brew autoremove.