How to clear the Homebrew cache on a Mac
By Vishva Variya · Updated · 3 min read
Short answer
Run brew cleanup --prune=all to delete every cached download, or plain brew cleanup to remove outdated downloads and old versions. The cache is in ~/Library/Caches/Homebrew (brew --cache shows it). Installed packages keep working; Homebrew downloads again only to reinstall or upgrade.
Where is the Homebrew cache on a Mac?
~/Library/Caches/Homebrew
Safe to clear. Downloaded installation files for Homebrew packages. Safe to delete and Homebrew will simply re-download them if you reinstall any packages.
How do I clear the cache with brew?
- 1Preview what would be removed: brew cleanup --dry-run (or -n).
- 2Remove stale lock files, outdated downloads and old versions of installed formulae: brew cleanup
- 3Remove every cached download: brew cleanup --prune=all
- 4Also scrub downloads for the latest versions: brew cleanup -s (downloads for installed formulae and casks are still kept).
How do I delete the Homebrew cache by hand?
- 1Find the cache folder with: brew --cache (usually ~/Library/Caches/Homebrew).
- 2Make sure no brew command is running.
- 3Move the folder's contents to the Trash, or run brew cleanup --prune=all.
What happens when you clear it?
Cached downloads are removed; installed packages keep working. Homebrew downloads them again only when you reinstall or upgrade. Plain brew cleanup also removes old versions of installed formulae.
Clearing it with Peekaboo
Peekaboo’s developer cleanup (turn on Show developer features in Settings) lists “Homebrew Package Cache” with its size and the note above, alongside every other cache it finds. It won’t offer a folder the app is still running from, and the cleanup goes to the Trash, so ⌥⌘Z puts it back.
- 1Open the developer cleanup.⇧⌘B
- 2Find Homebrew Package Cache, check its size, and move it to the Trash.
Questions
Does Homebrew clean up its cache by itself?
- Yes. Homebrew's FAQ says it uninstalls old versions of each formula upgraded with brew upgrade and does additional cleanup every 30 days (HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS, default 30). brew cleanup removes downloads more than 120 days old (HOMEBREW_CLEANUP_MAX_AGE_DAYS).
How do I delete everything in the Homebrew cache?
- Run brew cleanup --prune=all. The manpage says --prune removes cache files older than the days you give, and --prune=all removes everything.
How do I stop Homebrew cleaning up automatically?
- Set export HOMEBREW_NO_INSTALL_CLEANUP=1. To keep only some formulae, list them in HOMEBREW_NO_CLEANUP_FORMULAE.