How to uninstall Homebrew packages without leaving junk behind

Updated · by Nico Wickersheim

Removing a package with Homebrew takes one command, but doing it cleanly takes a little more: you want to avoid breaking other packages, remove leftover app files, and get rid of dependencies that nothing needs anymore.

1. Check what depends on the package

brew uses --installed openssl@3

This lists the installed formulae that need the package. If the list isn't empty, removing it will break them. brew deps --tree wget shows the opposite direction: what a package itself depends on.

2. Uninstall a formula

brew uninstall wget

Homebrew refuses to uninstall a formula that other installed formulae still require and tells you which ones. You can override this with --ignore-dependencies, but the dependent packages will probably stop working.

3. Uninstall a cask and its leftovers

brew uninstall --cask firefox

This removes the app, but settings, caches and other support files in ~/Library stay behind. To remove those too, use --zap:

brew uninstall --zap --cask firefox

Zap deletes the files listed in the cask's zap section. Use it only when you're sure you don't want the app's data anymore: some of those files may be shared with other apps from the same developer.

4. Remove dependencies nobody needs

Formulae that were installed only as a dependency stay on your Mac after you remove the package that needed them. brew autoremove finds and removes them. Preview the list first:

brew autoremove --dry-runbrew autoremove

Find packages you can safely remove

brew leaves

brew leaves lists the installed formulae that no other installed formula depends on. That's usually the list of things you installed yourself, and a good place to spot tools you no longer use.

Old versions and downloads take up space too. See how to free up disk space with brew cleanup.

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