How to free up disk space with brew cleanup

Updated · by Nico Wickersheim

Homebrew keeps downloaded installers in a cache and can leave older versions of packages behind. On a Mac that has used Homebrew for a while, this easily adds up to several gigabytes. brew cleanup gets that space back.

Check how big the cache is

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

brew --cache prints the location of Homebrew's download cache, usually ~/Library/Caches/Homebrew.

Preview what would be removed

brew cleanup --dry-run

The dry run lists every file and old version that cleanup would delete, without touching anything.

Run the cleanup

brew cleanup

This removes old versions of installed formulae and casks, stale lock files and outdated downloads (by default those older than 120 days). At the end Homebrew tells you how much space it freed. To clean up just one package, add its name: brew cleanup wget.

Empty the download cache completely

brew cleanup --prune=all

--prune=all removes all cached downloads regardless of age. You lose nothing but the ability to reinstall a package without downloading it again.

Doesn't Homebrew do this automatically?

Partly. After an upgrade, Homebrew removes the old versions of the packages it just upgraded, and it runs a full cleanup every 30 days. Running it yourself is still worth it when you need the space now, or after uninstalling a lot of packages. To remove dependencies that are no longer needed, see uninstalling packages cleanly.

Run brew doctor while you're at it

brew doctor

brew doctor checks your installation for common problems, such as broken symlinks or outdated settings, and explains how to fix each one.

Prefer clicking over typing?

WailBrew is a free, open-source Homebrew GUI for macOS. It runs the same brew commands for you, behind a fast native interface.

Download WailBrew

or brew install --cask wailbrew

More Homebrew guides