Homebrew cache on Mac: what brew cleanup removes, and what it keeps

Homebrew cache, explained: a blue folder labelled Homebrew with the Homebrew beer mug icon, tabbed ~/Library/Caches.

Yes, it's safe to delete ~/Library/Caches/Homebrew. It holds downloads, not the software you have installed, and Homebrew downloads anything it needs again. The usual command is:

brew cleanup

Before you run it, see how much space Homebrew is using and where. These commands only read sizes:

du -sh "$(brew --cache)" "$(brew --cellar)" "$(brew --caskroom)" ~/Library/Logs/Homebrew 2>/dev/null brew cleanup -n

The first line prints four folder sizes. The second is a dry run: it lists what brew cleanup would remove and ends with "This operation would free approximately" and a total. If it prints nothing, there's nothing to clean.

Homebrew's cache is often smaller than people expect, because Homebrew has trimmed it on its own since 2019. The space can also be in the Cellar (installed versions) or the Caskroom (app installers), which this guide covers too. The rules below come from Homebrew 7.0.10's documentation and source code.

Where Homebrew keeps its files

LocationFind it withWhat's in itDoes brew cleanup touch it?
~/Library/Caches/Homebrewbrew --cacheDownloaded bottles (prebuilt packages), cask installers, source code, Homebrew's package indexYes
/opt/homebrew/Cellar (Apple silicon), /usr/local/Cellar (Intel)brew --cellarEvery installed version of every formulaRemoves old versions
/opt/homebrew/Caskroom, /usr/local/Caskroombrew --caskroomCask records, plus installer files for some casksOnly broken links
~/Library/Logs/HomebrewLogs from buildsYes, after 30 days

The cache path is per user and doesn't depend on where Homebrew is installed. Homebrew sets it to ${HOME}/Library/Caches/Homebrew unless you change it with HOMEBREW_CACHE (Homebrew manpage).

What's inside the cache folder

To see what's taking the space:

du -sh "$(brew --cache)"/* 2>/dev/null | sort -h

Homebrew already cleans up, at times you might not expect

Since Homebrew 2.0 in February 2019, cleanup runs automatically (Homebrew 2.0.0). Before that, Homebrew kept every download and old version until you ran brew cleanup yourself, which is why older tips tell you to run it often.

Set HOMEBREW_NO_INSTALL_CLEANUP=1 and none of this happens. Homebrew's FAQ warns that with automatic cleanup off, uninstalling a formula only removes the latest version you have installed, not older ones (Homebrew FAQ).

What brew cleanup removes and what it keeps

The manpage gives the summary. The details below come from Homebrew's cleanup.rb and formula.rb (source on GitHub).

ItemPlain brew cleanupWith -s
Old versions of a formula, once the newest is installedRemovedRemoved
The version a formula is pinned to, or an old version that's still linkedKeptKept
Old versions of a formula you haven't upgraded yetKept, with "Skipping X: most recent version Y not installed"Kept
Downloads of outdated versionsRemovedRemoved
Any download more than 120 days old, installed or notRemovedRemoved
Current-version downloads of packages you've uninstalledKept until outdated or 120 days oldRemoved
Current-version downloads of packages you have installedKept until 120 days oldKept until 120 days old
Downloads of casks with no fixed version (version :latest)Removed after 30 daysRemoved if not installed
Build logs in ~/Library/Logs/HomebrewRemoved after 30 daysRemoved after 30 days
Source-build caches (cargo_cache, go_mod_cache and so on)Deleted whole on a full cleanup; npm and pnpm caches only lose old filesSame
Formulae installed only as dependencies that nothing needs nowUninstalledUninstalled
Old copies of Homebrew's own RubyRemoved (manual runs only, not the 30-day run)Removed
Installer files in the CaskroomNot touchedNot touched

Two rules from that table catch people out:

The commands, and the difference between them

CommandWhat it does
brew cleanup -nDry run. Lists what plain brew cleanup would remove, and the total, without removing anything
brew cleanupThe rules in the table above
brew cleanup -sAlso removes current-version downloads of packages you no longer have installed
brew cleanup --prune=allRemoves every cache file regardless of age, including downloads for installed packages. --prune=0 does the same
brew cleanup <formula or cask>Only that package's old versions and downloads
brew cleanup --prune-prefixOnly removes broken links and empty folders in the Homebrew prefix
rm -rf "$(brew --cache)"Deletes the whole cache. The manpage suggests it when you want even installed packages' downloads gone

Don't use --prune with a number to clean "harder": when you pass --prune=30, Homebrew removes files older than 30 days and skips its check for outdated downloads, so recent outdated files stay. Plain brew cleanup would have removed them. Use plain cleanup, or --prune=all if you want everything gone.

brew bundle cleanup is a different command: with --force it uninstalls every formula and cask that isn't listed in your Brewfile (Homebrew Bundle docs). It has nothing to do with the download cache.

When brew cleanup uninstalls formulae

Since Homebrew 4.3.0 (May 2024), brew cleanup and brew uninstall run brew autoremove for you (Homebrew 4.3.0). It uninstalls formulae that were installed only as a dependency and that nothing installed still needs. Because the 30-day automatic cleanup runs the same code, a brew upgrade can also autoremove formulae.

That's usually what you want. It goes wrong when you use a formula directly that first arrived as someone else's dependency, such as a language runtime. Once the formula that pulled it in is gone, cleanup removes it.

Check first:

brew autoremove -n

If something on the list is a tool you use, keep it with any of these:

Two reports on Homebrew's issue tracker show why the dry run is worth a few seconds. In 2024, a user who removed one cask watched Homebrew autoremove 89 formulae that had nothing to do with it. A Homebrew contributor traced it to old install records that didn't say whether each formula was installed on request, and changed autoremove so it only removes formulae explicitly marked as dependencies (Homebrew/brew #17572). In 2026, brew cleanup listed two libraries as unneeded while another installed formula still used them, and brew uninstall then refused to remove them (Homebrew/brew #21511).

The Caskroom: installers brew cleanup leaves behind

When a cask installs an app, Homebrew moves the app into /Applications. When a cask installs with a .pkg installer, Homebrew copies the .pkg into the Caskroom and leaves it there. The original download stays in the cache as well, and because the cask is installed, -s keeps it. It goes when it's 120 days old, with --prune=all, or when you delete it.

A Homebrew contributor confirmed that brew cleanup "does not touch files in */Caskroom by design" (Homebrew/brew #11912). In 2019 one user reported that the 4.13 GB mactex-no-gui installer took 8.26 GB this way, one copy in each place (Homebrew/homebrew-cask #74831). That's a single report, so check your own:

du -sh "$(brew --caskroom)"/* 2>/dev/null | sort -h | tail -10

Don't trim files inside the Caskroom by hand. Homebrew keeps its records of installed casks there and gives no supported way to slim them down.

Old versions and versioned formulae in the Cellar

To list formulae with more than one version installed:

brew list --multiple

Plain brew cleanup removes those old versions unless they're pinned, linked or waiting on an upgrade. Versioned formulae such as python@3.12 or node@22 are separate formulae, not old versions, so cleanup never removes them. If you no longer need one, uninstall it by name. To see what's biggest:

du -sh "$(brew --cellar)"/* | sort -h | tail -15

If cleanup stops with "Could not cleanup old kegs! Fix your permissions on:" and a Cellar path, some files in that old version aren't owned by your user, often after running something with sudo (Super User). Fix ownership of that one folder, for example with sudo chown -R "$(whoami)" followed by the path Homebrew printed, then run cleanup again. Don't run brew itself with sudo.

Two Homebrews on one Mac

If you moved from an Intel Mac to Apple silicon with Migration Assistant, you may have two installs: the old one in /usr/local and a new one in /opt/homebrew. Homebrew picked /opt/homebrew so the two could coexist (Homebrew FAQ), and its uninstall script has a comment saying the old path "will remain" after a migration.

ls -d /usr/local/Cellar /opt/homebrew/Cellar 2>/dev/null which -a brew

To remove the old install, download Homebrew's uninstall script and run it with --path. Homebrew's own instructions give this for the Intel to Apple silicon case (Homebrew/install):

curl -fsSLO https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh /bin/bash uninstall.sh --path /usr/local --dry-run

--dry-run lists what it would delete. Run it again without that option to remove the files. Without --path, the script on an Apple silicon Mac looks in /opt/homebrew first, which is the install you want to keep. By default the script also deletes ~/Library/Caches/Homebrew and ~/Library/Logs/Homebrew, which your remaining install shares. That only costs re-downloads, but --skip-cache-and-logs leaves them in place.

The uninstall script doesn't edit your shell profile. If you remove Homebrew completely, delete the eval "$(/opt/homebrew/bin/brew shellenv)" line the installer asked you to add to ~/.zprofile.

On Intel Macs, expect more source builds: Homebrew has stopped building new bottles for Intel, and on macOS Tahoe on Intel "updated formulae may build from source" (Homebrew Support Tiers). Source builds download source code, fill the build caches described above and need Apple's Command Line Tools. Homebrew plans to stop running on Intel Macs in or after September 2027.

Moving the cache or changing the rules

SettingEffect
HOMEBREW_CACHE=/Volumes/Work/HomebrewCacheDownloads go there instead of ~/Library/Caches/Homebrew
HOMEBREW_CLEANUP_MAX_AGE_DAYS=30Cleanup removes downloads older than 30 days instead of 120
HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS=7The automatic full cleanup can run every 7 days instead of 30
HOMEBREW_NO_INSTALL_CLEANUP=1No automatic cleanup at all
HOMEBREW_NO_CLEANUP_FORMULAE=foo,barNever clean up or autoremove these formulae
HOMEBREW_NO_AUTOREMOVE=1Cleanup and uninstall stop removing unneeded dependencies

Each variable needs a value. export HOMEBREW_NO_AUTOREMOVE on its own is ignored; export HOMEBREW_NO_AUTOREMOVE=1 works (Homebrew manpage).

You can put these lines in your shell profile, or in ~/.homebrew/brew.env, which Homebrew reads on every run however it was started. Write one NAME=value per line, without export. The file doesn't expand $HOME or ~, so give the full path, for example HOMEBREW_CACHE=/Users/you/HomebrewCache. After a change, brew --cache shows the folder Homebrew is using. Files in the old location stay put, so delete them once the new one works.

Deleting the folder by hand

Run brew cleanup --prune=all first. If you still want the folder gone:

  1. Make sure no brew command is running in another window.
  2. In Finder, choose Go > Go to Folder (Shift-Command-G), type ~/Library/Caches/Homebrew and press Return.
  3. Move its contents to the Trash, then empty the Trash.

Or in Terminal, rm -rf "$(brew --cache)", which deletes immediately with no Trash.

What you give up:

If rm says Permission denied: Go stores its module cache read-only. Homebrew's comment in cleanup.rb says it has to undo this before deleting, which brew cleanup does. Run brew cleanup --prune=all, then delete what's left.

If one download is bad: an install that fails with "SHA256 mismatch" names a file in ~/Library/Caches/Homebrew/downloads and says "To retry an incomplete download, remove the file above" (quoted in a Hacker News thread). Delete that file, or run brew fetch --force <formula>, which removes the cached copy and downloads it again. You don't need to wipe the whole cache.

How much space to expect

Homebrew has trimmed its cache on every install and upgrade since 2019, so there's often little left to clear. If yours is big, check whether automatic cleanup is turned off, whether you've gone months without an upgrade, and whether large cask installers are sitting in it. On X in October 2026, one developer listed what each cache command freed on their Mac: yarn cache clean 26 GB, uv cache clean 11 GB, npm cache clean --force 10 GB, and brew cleanup -s 2 GB (X post). That's one Mac. Measure yours with the du command at the top, and see how to clear cache on Mac for the other developer caches.

Leave these alone

Doing it with an app

Purge is a free, open-source Mac cleaner (source on GitHub). It lists ~/Library/Caches/Homebrew as "Homebrew Package Cache", shows its size, and marks it Safe. If you clean it, Purge moves the folder to the Trash, so you can put it back until you empty the Trash yourself. The space comes back when you do. Because it's marked Safe, it's included when you run Purge's safe clean or turn on scheduled cleaning.

Purge doesn't run brew. It doesn't remove old versions from the Cellar, touch the Caskroom, or autoremove formulae, so use brew cleanup and brew uninstall for those. It also looks for the cache only at the default path, so a cache you moved with HOMEBREW_CACHE won't show up.

Frequently asked questions

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

Yes. Installed formulae live in the Cellar and installed apps in /Applications, so they keep working. Homebrew downloads files again when you install, upgrade or reinstall, and it fetches its package index again on the next brew command, which needs an internet connection.

Does brew cleanup delete installed packages?

It removes old versions of formulae once the newest version is installed. Since Homebrew 4.3.0 it also uninstalls formulae that were only installed as dependencies and that nothing needs any more. Run brew autoremove -n to see that list first, and brew tab --installed-on-request <formula> to keep one.

What's the difference between brew cleanup -s and --prune=all?

-s also removes current-version downloads of packages you no longer have installed, but keeps downloads for installed packages. --prune=all removes every cache file regardless of age or install status.

Why didn't brew cleanup free much space?

Homebrew already cleans up after every install and upgrade, so there may be little left. The space may also be outside the cache: old versions of formulae you haven't upgraded yet, a second Homebrew in /usr/local, or .pkg installers in the Caskroom, which cleanup never touches.

How do I stop Homebrew from cleaning up automatically?

Set HOMEBREW_NO_INSTALL_CLEANUP=1 in your shell profile or in ~/.homebrew/brew.env. To protect only certain formulae, use HOMEBREW_NO_CLEANUP_FORMULAE=foo,bar. With automatic cleanup off, old versions pile up in the Cellar until you run brew cleanup yourself.

Sources