MacOS – How to cleanly remove Homebrew

homebrewmacos

How can I cleanly remove Homebrew. I might have a faulty older installation, and I'd like to have a fresh start.

Best Answer

This rm -rf will not ask if you are sure when you delete, so be sure the cd command works to get you out of /tmp (the cd /tmp gets you to a safe place in case you copy/paste everything in one go so you don't delete files from your current directory)

Try this in your Terminal:

cd /tmp
cd `brew --prefix`
rm -rf Cellar
brew prune
rm `git ls-files`
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions
rm -rf .git
rm -rf ~/Library/Caches/Homebrew

More info about this topic can be found in the Homebrew FAQ.