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.

These commands permanently delete files. Most are caches the tool rebuilds on its own (the next build or install is slower and may need internet). Anything that can hold data you cannot re-download is flagged on the page. Read each command, then copy and run it yourself. devdisk never runs cleanup commands for you.

Where it lives

Any OS with Homebrew
brew --cache

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

macOS / Linux
brew cleanup -n    # dry run: lists what would be removed

Clear it

macOS / Linux
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

macOS / Linux
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.

macOS / Linux
curl -fsSLO https://disk.sadana.app/devdisk.py && python3 devdisk.py
Windows (PowerShell)
iwr https://disk.sadana.app/devdisk.py -OutFile devdisk.py; py devdisk.py

Run free scannerSample report

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.

More cleanup guides