90

How to remove all homebrew packages wich are not used by any other package?
Some packages are installed as dependency of other package. When packages are removed, dependent packages stay as leftovers.

apt support the autoremove command for example. Is there such command in hombrew?

2 Answers 2

127

You can get rid of all unused dependencies using brew autoremove in HomeBrew versions 2.5.9 and above.

The autoremove functionality was added in this commit on 5 Nov 2020.

1
  • This also removes some packages that are listed in brewfile, why is that?
    – stevemao
    Commented Jun 24, 2021 at 3:03
57

Found on linuxbrew issue

brew bundle dump
brew bundle --force cleanup 

brew now supports Brewfiles. brew bundle dump generates a Brewfile with all the packages installed by user. Dependent packages are not listed here

example:

brew "python3"
brew "curl"
brew "tmux"
brew "neovim"

This file can be used to install the same software automatically. But also for doing a cleanup of unused packages. Edit the file then keep only the packages you need. Then run brew bundle --force cleanup. It will remove everything not listed or depending on the packages in the file.

WARNING: Also not listed casks will be removed

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .