Clean up Homebrew: old versions, downloads and unused dependencies
What brew cleanup removes, how to preview it, how to clear the download cache completely, and how to remove dependencies nothing needs any more.
Homebrew keeps the installer for every formula and cask it has downloaded, and old versions of formulae after an upgrade. It tidies some of this by itself, but the download cache in particular grows quietly.
See what is there
du -sh "$(brew --cache)" # downloaded bottles and casks
brew cleanup -n # dry run: what cleanup would remove, and how much
Clean
brew cleanup # old versions, and downloads older than 120 days
brew cleanup --prune=all # also every cached download, whatever its age
brew autoremove # formulae installed only as dependencies that nothing needs now
brew cleanupnever removes the installed, current version of anything.- After
--prune=all, reinstalling a formula downloads it again. That is the whole cost. - Run
brew autoremovewith a glance at its list first: a tool you use directly but installed as a dependency will be on it.
Leave the Cellar alone
Do not delete things under /opt/homebrew or /usr/local by hand. Homebrew tracks what it installed there, and a manual delete leaves it believing the files still exist.
How Siftaway handles this
Siftaway reports the Homebrew download cache with its size and the matching brew cleanup command, and treats /opt/homebrew and /usr/local as never-delete locations. Cleaning the download cache is part of the free tier.