Skip to cookie settings

Homebrew cache: where it is and how much brew cleanup frees

Homebrew keeps downloaded installers in one folder. Here is how to find it, preview a cleanup and understand why the number can be small.

Part of: Mac disk cleanup for developers: every cache, what it costs to rebuild (Developers)

Run brew --cache to find the Homebrew cache folder. Run brew cleanup -n to see what a cleanup would remove, without removing anything. The cache is usually small compared with Xcode or Gradle, so this is a minute of work, not a big win.

Find the cache

brew --cache

On a default install it points to a folder named Homebrew in ~/Library/Caches. That folder holds the files Homebrew downloaded before installing them: installers and source archives.

To see its size:

du -sh "$(brew --cache)"

The quotes matter if the path ever contains a space.

Preview a cleanup

brew cleanup has a dry run. The -n flag, short for --dry-run, lists what would be removed and changes nothing:

brew cleanup -n

Read the list. If it names formulae you still use at the current version, nothing will break: cleanup removes old versions and old downloads. It does not touch the version you have installed. The command may also print warnings such as a package it skipped because the latest version is not installed. Those lines are not errors.

Why it can print nothing

The question “why does brew cleanup show no output?” usually has a dull answer. Homebrew already cleans up after itself on many installs and upgrades. If nothing is outdated, the command has nothing to report. That is good news, not a bug.

Safe, risky, never

  • Safe: the real cleanup (the same command without -n) after a dry run, and the downloads in the cache folder. Cost: if you reinstall a package, Homebrew downloads it again.
  • Risky: deleting the cache folder while a brew install or brew upgrade is running. Wait for it to finish.
  • Never: do not remove the Homebrew install itself, usually /opt/homebrew on Apple silicon Macs, to get space back. It holds the packages you installed, not just a cache.

What clearing it costs

Removing old downloads costs one download if you reinstall that package. Removing old versions means you cannot roll back to them without downloading them again. If you pin a package to an older version on purpose, check the dry run list before you accept it.

How much space will it free?

It depends on how long it has been since you last cleaned and how many packages you upgrade. On the Mac used to check this article, the cache was small. Large casks, which are installers for desktop apps, are what make it big. Check with du -sh before expecting a lot.

Other places Homebrew data lives

The cache is not the whole story. Installed packages sit in the Homebrew folder, which holds old versions until cleanup removes them. If space is still tight after cleanup, look at the other developer folders instead. See the developer cleanup guide, the npm cache and the pip cache.

If you are unsure how caches differ from other Library data, read what is safe to delete in Library/Caches.

Worked example: reading a dry run

Here is what brew cleanup -n printed on the Mac used to check this article. The list had one large item and several tiny ones:

  • A bootsnap folder under the Homebrew cache, with 1,121 files and 10.5 MB.
  • A few small folders under /opt/homebrew/var/homebrew/tmp/.caskroom, each a few hundred bytes. They are named after apps that were installed as casks.
  • A last line saying the operation would free about 10.5 MB.

So a real cleanup here would give back about ten megabytes. That is the honest size of the job on a Mac that is kept up to date. If your total is that small, you can skip it.

The dry run never changed anything. Running it twice gives the same list.

Check where Homebrew lives

brew --prefix

On Apple silicon Macs this printed /opt/homebrew. On Intel Macs the usual answer is /usr/local. Knowing the prefix helps you read the paths in a cleanup list. The cache is in your home folder. The installed packages are under the prefix. Cleanup touches the old parts of both, not the current versions.

If something goes wrong

  • A command prints an error about a tap or a cask. Homebrew may refuse something it does not trust. Read the message. It names the fix. This is a Homebrew setting, not a disk problem.
  • You need an old version again. Cleanup removed it. Install it again, and expect a download.
  • du shows a bigger cache than the dry run says you would free. Cleanup only removes outdated items, not everything in the folder. The current downloads stay.
  • Nothing is freed. There was nothing outdated. See the section above on why it can print nothing.

When not to clean

If you pinned a package to an old version on purpose, do not run the real cleanup before you read the dry run. If your disk has plenty of room, skip it altogether.

See the size in a scan

DiskJoy is our product. Its scan reads your disk and shows how large the Homebrew cache is next to other developer data, read-only. Cleanup is not built yet, so DiskJoy does not remove it today. For now, use Homebrew’s own cleanup as above.

Quick checklist

  1. brew --cache to find the folder.
  2. du -sh "$(brew --cache)" for its size.
  3. brew cleanup -n to preview.
  4. Run the same command without -n only if the preview looks right.

Frequently asked questions

How do I clear the Homebrew cache?

Homebrew has a cleanup command that removes old versions of installed packages and old downloads. Run it first with the -n flag (brew cleanup -n) to see what it would remove without deleting anything, then run it again without -n if the list looks right.

Where is the Homebrew cache?

Run brew --cache. On the Mac used to check this article it printed a folder named Homebrew inside the user Library Caches folder. Your path can differ if you set a custom one.

Why does brew cleanup print nothing?

Because there was nothing old to remove, or only warnings about packages it skipped. Cleanup removes outdated versions, so a Mac that is already tidy sees no output.

Tags:Homebrewbrew cleanupCaches

See what’s taking up space on your Mac

DiskJoy explains every item and removes nothing until you review it.
Download for Mac

Cookies on diskjoy.com

Your browser sends a Global Privacy Control signal. We honoured it: analytics and marketing cookies are off.

Necessary cookies run this site. Analytics shows us how it is used: if you accept it, Google receives data about your visit. Change this anytime in Cookie Settings. How Google uses data Cookie Policy Privacy policy

Customize

Purpose
Needed for the site to work and to remember your cookie choice.

Cookies

  • sy_consent - Stores your cookie choice (Retention: 12 months)

Other browser storage

  • sy_consent_pending (localStorage) - Queues your choice until it reaches our server (Retention: until deleted)
Purpose
Show us which pages are visited and how the site is used, so we can improve it. Provider: Google Ireland Ltd (Google Analytics 4).

Cookies

  • _ga - Distinguishes visitors to count them (Retention: 400 days)
  • _ga_TP2XMLG27P - Keeps the state of your current visit (Retention: 400 days)

Recipients

Data controller

Sylentis Group sp. z o.o.. Contact: support@diskjoy.com. Privacy policy

Google may process data outside the European Economic Area (EEA). Safeguards: EU-US Data Privacy Framework, standard contractual clauses.

Right to withdraw

You can withdraw consent at any time, as easily as you gave it. Withdrawal does not affect the lawfulness of processing before it.