Guide

brew cleanup: what Homebrew removes and how to go further

Old versions, the download cache and orphaned dependencies: what each Homebrew cleanup command takes and what stays.

By Rachid Almaach · November 2026

Every brew upgrade installs the new version of a formula next to the old one and only then switches over. Homebrew does remove the old version afterwards, but not always, and not the downloads it kept to install it. A Mac that has run Homebrew for a few years carries old versions in the Cellar and a download cache that is often larger than everything it installed.

Where the space is

Installed formulae live in the Cellar (/opt/homebrew/Cellar on Apple silicon, /usr/local/Cellar on Intel), casks in the Caskroom next to it. Downloads go to the cache:

brew --cache
# usually ~/Library/Caches/Homebrew
du -sh "$(brew --cache)"
du -sh "$(brew --cellar)"

To see which formulae have more than one version installed:

brew list --versions | awk 'NF > 2'

Doesn't Homebrew clean up by itself?

Partly. Since 2019 Homebrew runs brew cleanup for the formula or cask it just installed or upgraded, and a full cleanup roughly every 30 days when you install or upgrade something. It does not run when you don't use Homebrew for a while, and the automatic run leaves cache downloads younger than 120 days. Setting HOMEBREW_NO_INSTALL_CLEANUP=1 in your shell turns the automatic cleanup off, which is why some Macs have none of it: someone set that once to make installs faster.

How to run brew cleanup

Start with a dry run. It lists what would go and how much that frees, and deletes nothing:

brew cleanup -n

Then the real thing:

brew cleanup

This removes old versions of every installed formula and cask, lock files, and cache downloads older than 120 days. Only one formula:

brew cleanup node

Going further

The download cache is often the biggest part and is only there to reinstall without downloading again. --prune sets how old a download has to be to go; all means every download, whatever its age:

brew cleanup --prune=all

-s (scrub) also removes the downloads of the versions you have installed right now, which the default keeps around:

brew cleanup -s

Separately from old versions, formulae that were only installed as a dependency of something you have since uninstalled stay installed. brew autoremove finds and removes them. Dry run first, because a tool you use directly but that Homebrew only knows as a dependency, since it came in with something else, shows up here too:

brew autoremove -n
brew autoremove

And if you'd rather Homebrew did all of this on its own: set HOMEBREW_CLEANUP_MAX_AGE_DAYS to a lower number than 120 in your shell profile, and make sure HOMEBREW_NO_INSTALL_CLEANUP is not set. brew --env and man brew list the variables your version supports.

What is safe to delete

The cache. Everything in ~/Library/Caches/Homebrew is a download Homebrew repeats when it needs it. You can rm -rf the folder, brew cleanup --prune=all does the same with the bookkeeping intact.

Old versions in the Cellar, with two exceptions. A formula you pinned with brew pin keeps its version and brew cleanup leaves it alone. And a program that was running before the upgrade may still be the old binary: a Homebrew service (brew services list) started last week runs the version from last week until you restart it. Restart your services after a cleanup if something behaves oddly; brew services restart <name> does it.

Not safe to delete by hand: anything in the Cellar or Caskroom outside of brew commands. Removing a version folder yourself leaves broken symlinks in /opt/homebrew/bin and a formula Homebrew thinks is installed. Use brew uninstall for things you no longer want, and brew cleanup for old versions.

Or let Sluice do it

Sluice, a menu bar disk cleaner for developer Macs, lists the Homebrew download cache next to the other package caches on your Mac (npm, Yarn, Bun, pip, uv, Poetry, CocoaPods, SwiftPM, Maven, Composer, NuGet, Deno) with its size, and clears the ones you pick when you ask. It does not touch the Cellar or installed versions; brew cleanup and brew autoremove are the right tools for those. Sluice is free to download and clean with; Pro cleans every night and whenever space runs low.

macOS 14 Sonoma or later · Apple silicon and Intel · or brew install --cask qraft/tap/sluice

FAQ

What does brew cleanup remove, exactly?

Old versions of installed formulae and casks (every version except the current and any pinned one), stale lock files, and cached downloads older than 120 days. It leaves current versions, the downloads for them, and anything not installed through Homebrew. brew cleanup -n shows the list for your Mac before anything goes.

Is it safe to delete ~/Library/Caches/Homebrew?

Yes. It holds downloaded bottles and cask installers, and Homebrew downloads them again when it needs them. The only cost is bandwidth the next time you reinstall or upgrade something it had cached. brew cleanup --prune=all empties it through Homebrew; deleting the folder in Finder works too.

Why does brew upgrade leave old versions around at all?

Homebrew keeps the old version until the new one is installed and linked, so a failed upgrade leaves you with a working tool. The old version is meant to be removed by the cleanup that follows, and usually is. With HOMEBREW_NO_INSTALL_CLEANUP set, or on a Mac that only runs brew install once in a while, the cleanup falls behind and the versions pile up.