The Homebrew cache that brew cleanup leaves behind
brew cleanup is not the whole story. The download cache and old versions in the Cellar survive it, and together they are usually several gigabytes.
Running brew cleanup and watching it report a few hundred megabytes is a familiar disappointment. The command is doing what it says; the point is that what it says is narrower than most people assume.
The two piles, and only one gets cleaned
Homebrew keeps every download it has ever made in a cache, separately from the packages it has installed. Find it with:
brew --cache
du -sh "$(brew --cache)"On a machine that has been developing for a year, that number is regularly 5 to 15 GB. Plain brew cleanup removes only the stale part of it, leaving recent downloads in place on the theory that you might reinstall.
Clearing it properly
Three commands, in increasing order of how much they take:
| Command | What it removes |
|---|---|
| brew cleanup | Old versions of installed packages, and downloads past their retention window |
| brew cleanup --prune=all | The same, plus every cached download regardless of age |
| brew autoremove | Packages that were installed only as a dependency of something since removed |
To see what a run would take before it takes it, add the dry run flag. This is worth doing once, because the output is also the clearest inventory of the cache you will get:
brew cleanup --prune=all -nThe third pile: old versions in the Cellar
Upgrading a package does not always remove the version it replaced. Those live under the Cellar, and a long lived machine can hold several versions of the same large package:
du -sh $(brew --cellar)/* | sort -h | tail -20That command prints the twenty largest packages, smallest of the twenty first. brew cleanup is what removes the superseded versions, so if you have never run it, this is where a surprising amount of the space is.
Where this sits in the bigger picture
A package cache is rarely the largest thing on a developer's Mac. It is worth clearing because it is completely safe to clear, but if the goal is real space then the build folders and container images are the bigger prize: see Xcode derived data, what Docker is really using and node_modules across every project.
Common questions
Where is the Homebrew cache on a Mac?
Run brew --cache to print the exact path, which is normally inside ~/Library/Caches. It holds every package archive Homebrew has downloaded, and it is separate from the packages themselves, so clearing it does not uninstall anything.
Why does brew cleanup free so little space?
Plain brew cleanup only removes downloads past a retention window, keeping recent ones in case you reinstall. brew cleanup --prune=all removes the cached downloads regardless of age, which on a year old machine is usually several gigabytes rather than a few hundred megabytes.
Is it safe to delete the Homebrew cache?
Yes. The cache holds downloaded archives, not installed software or configuration. The only consequence is that reinstalling the same version has to download it again.