CleanMate

All guides · macOS · Updated

Homebrew eating disk space on a Mac: brew cleanup, autoremove, the download cache and old versions

Where Homebrew keeps its files on a Mac and the safe commands to shrink it: brew cleanup and --prune=all, brew autoremove, the download cache in ~/Library/Caches/Homebrew, old formula versions, cask apps and HOMEBREW_NO_INSTALL_CLEANUP.

Download for macOS — free and open source

CleanMate Smart Scan on a Mac, listing the Homebrew cache and unused Homebrew dependenciesCleanMate Smart Scan on a Mac, listing the Homebrew cache and unused Homebrew dependencies

Homebrew rarely deletes anything right away. It keeps the bottles and cask installers it downloaded, the old version of a formula after an upgrade until the next cleanup, and every dependency of a formula you uninstalled. On a Mac used for a few years, that is often several GB.

Three places hold it:

See how big they are:

du -sh "$(brew --cache)" "$(brew --prefix)/Cellar" "$(brew --prefix)/Caskroom" 2>/dev/null

brew cleanup

brew cleanup -n            # dry run: what would go, and how much
brew cleanup               # old formula versions, stale downloads, downloads older than 120 days
brew cleanup --prune=all   # also every cached download, whatever its age

brew cleanup removes old versions of formulae (only the newest stays in the Cellar), stale lock files and outdated downloads of formulae and casks. --prune=all empties the download cache too: nothing installed breaks, but a reinstall downloads again. Name a formula or cask (brew cleanup node) to clean only that one.

brew autoremove

brew autoremove -n   # dry run: formulae installed only as dependencies that nothing needs any more
brew autoremove

When you uninstall a formula, the dependencies it pulled in stay. brew autoremove removes those no installed formula needs. Read the dry run first: a tool you started using directly but never installed by name would go too (brew install it by name to keep it).

Old versions

brew list --versions          # formulae with every installed version
brew list --versions --cask   # casks with their version

A formula with two versions after its name still has the old one; brew cleanup <formula> removes it. A formula pinned with brew pin keeps its version and is skipped by brew upgrade.

A cask app that updates itself (Chrome, VS Code, Slack) can leave Homebrew’s record on an old version: the app in /Applications is current and the Caskroom folder is small. The cask installers left in the cache are what take space, and brew cleanup removes the outdated ones.

Automatic cleanup

Homebrew cleans the formula you just installed or upgraded, and runs a full brew cleanup every 30 days. To change that, set in your shell profile:

If HOMEBREW_NO_INSTALL_CLEANUP is set and you did not mean it, remove it and run brew cleanup.

Uninstalling a cask app

brew uninstall --cask <token> removes the app and Homebrew’s record. --zap also removes the app’s data in ~/Library, which you may want to review first. Dragging a cask app to the Trash leaves the record, and brew upgrade can install it again. See uninstall Mac apps completely.

How CleanMate does it

On a Mac (all macOS features), CleanMate runs Homebrew’s own commands, never with --force or --zap, and shows the sizes Homebrew’s dry runs report.

The Ubuntu app does not handle Homebrew. For the rest of a developer Mac, see Free up disk space on a Mac as a developer, node_modules and old build folders and old runtime versions. To compare CleanMate with other cleaners, see the comparison.

FAQ

Is brew cleanup safe? Yes. It removes only old versions and downloads; the newest version of everything you installed stays and keeps working.

How much space will brew cleanup free? Run brew cleanup -n --prune=all: its last line says how much. Often a few hundred MB to several GB.

Does brew cleanup remove cask apps? No. It removes old cask downloads, never an installed app.

What is the difference between brew cleanup and brew autoremove? cleanup removes old versions and downloads; autoremove uninstalls formulae that were only dependencies of formulae you removed.

Looking for a Pearcleaner alternative that is still updated? See how CleanMate compares.

Skip the commands

Open source — star it on GitHub: CleanMate for macOS

How CleanMate decides what is safe to remove →