The Computer Oracle

How to clean unused homebrew dependencies

Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn

--

Track title: CC H Dvoks String Quartet No 12 Ame

--

Chapters
00:00 Question
00:34 Accepted answer (Score 106)
00:57 Answer 2 (Score 56)
01:53 Thank you

--

Full question
https://superuser.com/questions/1509212/...

Accepted answer links:
[this]: https://github.com/Homebrew/brew/commit/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#macos #homebrew

#avk47



ACCEPTED ANSWER

Score 128


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.




ANSWER 2

Score 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