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 cleanupBefore 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 -nThe 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
| Location | Find it with | What's in it | Does brew cleanup touch it? |
|---|---|---|---|
~/Library/Caches/Homebrew | brew --cache | Downloaded bottles (prebuilt packages), cask installers, source code, Homebrew's package index | Yes |
/opt/homebrew/Cellar (Apple silicon), /usr/local/Cellar (Intel) | brew --cellar | Every installed version of every formula | Removes old versions |
/opt/homebrew/Caskroom, /usr/local/Caskroom | brew --caskroom | Cask records, plus installer files for some casks | Only broken links |
~/Library/Logs/Homebrew | Logs from builds | Yes, 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- downloads: the actual files. Homebrew names each one after a hash of its URL plus the package name and version (Homebrew Tips and Tricks). The
name--versionentries at the top level and inCaskare links to these. - Cask: links to downloaded app installers (.dmg, .zip, .pkg).
- api: the formula and cask data Homebrew reads to know what exists. If it's missing, Homebrew downloads it again, so the next
brewcommand after a full wipe needs an internet connection. - cargo_cache, go_mod_cache, npm_cache, pip_cache and similar: these only appear if you build formulae from source. Homebrew points Cargo, Go, npm and other package managers at these folders during builds (Formula Cookbook). Installing a bottle never uses them.
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.
- After each install, upgrade or reinstall: Homebrew runs cleanup for the packages involved. That removes their old versions and outdated downloads.
- Every 30 days: the same commands also run a full cleanup if the last one was more than 30 days ago (Homebrew manpage). This isn't a background job. It only happens when you run
brew install,brew upgradeorbrew reinstall, so a Mac where you never do that never gets cleaned. - The 30-day clock lives in the cache: Homebrew records the last full cleanup in a file named
.cleanedinside the cache folder. If you delete the whole folder, Homebrew starts the 30 days again. - The 30-day run also uninstalls unneeded dependencies: see when brew cleanup uninstalls formulae.
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).
| Item | Plain brew cleanup | With -s |
|---|---|---|
| Old versions of a formula, once the newest is installed | Removed | Removed |
| The version a formula is pinned to, or an old version that's still linked | Kept | Kept |
| Old versions of a formula you haven't upgraded yet | Kept, with "Skipping X: most recent version Y not installed" | Kept |
| Downloads of outdated versions | Removed | Removed |
| Any download more than 120 days old, installed or not | Removed | Removed |
| Current-version downloads of packages you've uninstalled | Kept until outdated or 120 days old | Removed |
| Current-version downloads of packages you have installed | Kept until 120 days old | Kept until 120 days old |
Downloads of casks with no fixed version (version :latest) | Removed after 30 days | Removed if not installed |
| Build logs in ~/Library/Logs/Homebrew | Removed after 30 days | Removed 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 files | Same |
| Formulae installed only as dependencies that nothing needs now | Uninstalled | Uninstalled |
| Old copies of Homebrew's own Ruby | Removed (manual runs only, not the 30-day run) | Removed |
| Installer files in the Caskroom | Not touched | Not touched |
Two rules from that table catch people out:
- "Most recent version not installed": Homebrew won't remove old versions of a formula until the newest version is in the Cellar. Run
brew upgrade <formula>first, then clean up (Ask Different). - Age is checked on both timestamps: a download counts as older than 120 days only when its modification time and its status-change time are both older than that.
The commands, and the difference between them
| Command | What it does |
|---|---|
brew cleanup -n | Dry run. Lists what plain brew cleanup would remove, and the total, without removing anything |
brew cleanup | The rules in the table above |
brew cleanup -s | Also removes current-version downloads of packages you no longer have installed |
brew cleanup --prune=all | Removes 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-prefix | Only 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 -nIf something on the list is a tool you use, keep it with any of these:
- Mark it as yours:
brew tab --installed-on-request <formula>. Homebrew's manpage describes this as the way to stopbrew autoremoveremoving a formula. - Protect it by name:
HOMEBREW_NO_CLEANUP_FORMULAE=<formula>. Homebrew then refuses to clean up or autoremove it, and its dependencies stay too. Its old versions also stay in the Cellar. - Turn it off:
HOMEBREW_NO_AUTOREMOVE=1. Cleanup still clears the cache and old versions.
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- To free a cask's Caskroom space: uninstall it with
brew uninstall --cask <name>. That deletes its version folder in the Caskroom. - To drop just the cached copy:
brew --cache --cask <name>prints the path of that cask's download, which you can then delete.
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 --multiplePlain brew cleanup removes those old versions unless they're pinned, linked or waiting on an upgrade. Versioned formulae such as [email protected] 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 -15If 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- Cleanup only cleans one of them:
brew cleanupworks on the install whosebrewyou run. The old Cellar in/usr/localkeeps whatever it had. - They share one cache: both use
~/Library/Caches/Homebrew, since the cache path depends on your user, not the install. - The old one can't install anything natively: on Apple silicon, a
/usr/localHomebrew stops with "Cannot install in Homebrew on ARM processor in Intel default prefix" and suggestsbrew bundle dumpto move your list of formulae across.
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
| Setting | Effect |
|---|---|
HOMEBREW_CACHE=/Volumes/Work/HomebrewCache | Downloads go there instead of ~/Library/Caches/Homebrew |
HOMEBREW_CLEANUP_MAX_AGE_DAYS=30 | Cleanup removes downloads older than 30 days instead of 120 |
HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS=7 | The automatic full cleanup can run every 7 days instead of 30 |
HOMEBREW_NO_INSTALL_CLEANUP=1 | No automatic cleanup at all |
HOMEBREW_NO_CLEANUP_FORMULAE=foo,bar | Never clean up or autoremove these formulae |
HOMEBREW_NO_AUTOREMOVE=1 | Cleanup 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:
- Make sure no
brewcommand is running in another window. - In Finder, choose Go > Go to Folder (Shift-Command-G), type
~/Library/Caches/Homebrewand press Return. - 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:
- Offline reinstalls: anything you reinstall gets downloaded again.
- The package index: the next
brewcommand downloads it again before it does anything else. - The cleanup clock: the 30-day timer starts over.
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
- Folders in the Cellar or Caskroom: use
brew uninstall, so Homebrew's links and records stay in step with what's on disk. - /Library/Developer/CommandLineTools: Apple's Command Line Tools, not part of Homebrew's cache. Homebrew needs them to build from source, and on Intel Macs to install bottles too (Homebrew Installation).
sudo breworsudo rm -rfon the cache: Homebrew's files belong to your user. Running cleanup orrm -rfas root only raises the stakes of a typo.- The Caches folder above Homebrew: delete inside
~/Library/Caches/Homebrew, not~/Library/Cachesitself.
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
- Homebrew, brew(1) manpage (cleanup, autoremove, tab, list --multiple, fetch --force, --cache, --caskroom, environment variables, brew.env): docs.brew.sh/Manpage
- Homebrew, FAQ (automatic cleanup, keeping old versions, where downloads go, default prefixes): docs.brew.sh/FAQ
- Homebrew, Tips and Tricks (downloads folder naming): docs.brew.sh/Tips-and-Tricks
- Homebrew, Formula Cookbook (package manager caches used by source builds): docs.brew.sh/Formula-Cookbook
- Homebrew, Support Tiers (Intel bottles and end of Intel support): docs.brew.sh/Support-Tiers
- Homebrew, Installation (developer tools requirements): docs.brew.sh/Installation
- Homebrew, Homebrew Bundle and Brewfile (brew bundle cleanup): docs.brew.sh/Brew-Bundle-and-Brewfile
- Homebrew, 2.0.0 release notes (automatic cleanup): brew.sh/2019/02/02/homebrew-2.0.0/
- Homebrew, 4.3.0 release notes (autoremove by default): brew.sh/2024/05/14/homebrew-4.3.0/
- Homebrew source, cleanup.rb, cmd/cleanup.rb, formula.rb, utils/autoremove.rb, package_manager_cache.rb: github.com/Homebrew/brew
- Homebrew, uninstall script: github.com/Homebrew/install
- GitHub, Homebrew/brew #11912, brew cleanup is leaving installs in the caskroom: github.com/Homebrew/brew/issues/11912
- GitHub, Homebrew/homebrew-cask #74831, Improve the way to keep large pkg dmg files: github.com/Homebrew/homebrew-cask/issues/74831
- GitHub, Homebrew/brew #17572, Removing a cask triggers autoremove: github.com/Homebrew/brew/issues/17572
- GitHub, Homebrew/brew #21511, brew cleanup says libthai can be removed: github.com/Homebrew/brew/issues/21511
- Ask Different, brew cleanup: Warning: Skipping XXX: most recent version X not installed: apple.stackexchange.com/questions/371175
- Super User, Error: Could not cleanup old kegs! Fix your permissions on: superuser.com/questions/1759738
- Hacker News, user discussion with a SHA256 mismatch in the Homebrew cache: news.ycombinator.com/item?id=42754907
- X, @mattiasgeniar, cache cleanup sizes on one Mac: x.com/mattiasgeniar/status/2109612238214709333
