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@3This 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 wgetHomebrew 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 firefoxThis removes the app, but settings, caches and other support files in ~/Library stay behind. To remove those too, use --zap:
brew uninstall --zap --cask firefoxZap 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 autoremoveFind packages you can safely remove
brew leavesbrew 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.