How to uninstall Homebrew?

151

90

I’ve got some problems with the package manager, Homebrew. I can’t find how to remove it!

Is it safe to remove whole /usr/local? Homebrew was installed somewhere in that directory.

holms

Posted 2010-10-26T23:05:35.780

Reputation: 2 897

Answers

224

Homebrew once recommended a script, also linked in their FAQ. Instructions have changed since then, and they provide an official uninstall script you can download and run:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Here is a copy of the old script, for historical purposes:

cd `brew --prefix`
git checkout master
git ls-files -z | pbcopy
rm -rf Cellar
bin/brew prune
pbpaste | xargs -0 rm
rm -r Library/Homebrew Library/Aliases Library/Formula Library/Contributions 
test -d Library/LinkedKegs && rm -r Library/LinkedKegs
rmdir -p bin Library share/man/man1 2> /dev/null
rm -rf .git
rm -rf ~/Library/Caches/Homebrew
rm -rf ~/Library/Logs/Homebrew
rm -rf /Library/Caches/Homebrew

This should also revert your /usr/local folder to its pre-Homebrew days. See the Homebrew installation wiki for more information.

Note: You may also need to remove ~/.homebrew as well. If you happen to have ~/.rvm, then you should delete ~/.rvm/bin/brew.

speedofmac

Posted 2010-10-26T23:05:35.780

Reputation: 2 887

2If the first line of this script fails it will try to delete whatever is in your pasteboard. That could be a lot of your data. – ade – 2016-01-16T23:05:06.820

@ade: :/ Too Late. – Sunny R Gupta – 2016-03-11T09:08:12.183

"This should also revert your /usr/local" which of the scripts does this refer to? Will this also uninstall all packages installed by brew (my guess is no). – qubodup – 2016-04-04T12:09:38.427

I don't understand why I installed this crap. When trying uninstalling it, it asks me if I want to delete following files - then a list comes where it also wants to delete the entire /usr/local/Library/. Wtf? It contains other files too, like MySQL stuff. It seems that homebrew was installed directly to /user/local/. WTF?!? – StanE – 2016-09-06T00:25:05.440

thank you so much! i've googled so hard, but even't bothered to look for uninstallation actions in installation manual! ;D – holms – 2010-10-28T15:36:24.193

13

Note that the instructions have changed over time, and also been moved to the Homebrew FAQ https://github.com/mxcl/homebrew/wiki/FAQ/1ef6c2cf55db89252949c7bb2908abe093a3414a

– Nelson – 2011-09-10T23:19:14.997

Following these commands deleted almost all my files on Desktop, Documents and 'Downloads`. It messed up my git too. Please help! – Ava – 2013-08-16T22:53:45.400

rm -rf Library/Taps – Googol – 2014-03-13T13:25:21.793

and also: rm -rf /Library/Caches/Homebrew – itinance – 2014-04-27T08:01:20.683

Look also for LaunchAgents:

/Users/$username/Library/LaunchAgents – itinance – 2014-04-27T08:02:40.943

35

Homebrew now provides an uninstall script located here.

Just run the following in the OSX terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

RNickMcCandless

Posted 2010-10-26T23:05:35.780

Reputation: 453

1good one, just simple solution – AMIC MING – 2016-03-06T04:20:56.073

8

Also note that homebrew changes group to 'staff' and gives write access to group for

  • /usr/local
  • /usr/local/bin
  • /usr/local/include
  • /usr/local/lib
  • /usr/local/sbin
  • /usr/local/share

In order to put back these directories in their original states do:

sudo chown root:wheel <directory> ; sudo chmod 755 <directory>

for each one or if you don't have fancy owners / rights:

sudo chown -R root:wheel /usr/local ; sudo chmod -R 755 /usr/local

mecano

Posted 2010-10-26T23:05:35.780

Reputation: 93

1I cannot confirm this. My /usr/local and its Homebrew-created subdirs are owned by my user with the admin group. – slhck – 2012-12-26T16:21:14.223

1

Try this gist, it uninstalls homebrew and associated caches, provided you installed brew to the default directory.

thomax

Posted 2010-10-26T23:05:35.780

Reputation: 119

how do you use a gist? – ninja08 – 2015-02-13T21:36:06.050

@ninja08 Click on the link. Open a terminal window. Copy all of the gist's text into the terminal. – Spotlight – 2015-08-10T21:13:30.943

0

I recently made a script to handle this case. It completely removes Homebrew, and has CLI options like silent/verbose and force modes, as well as mode that returns the location of your Homebrew installation.

Steve Benner

Posted 2010-10-26T23:05:35.780

Reputation: 101

-3

There might be other files in /usr/local you might need you might be able to user a different PM (Package Manager) to remove the current PM.

Lightly Salted

Posted 2010-10-26T23:05:35.780

Reputation: 777

PM = Package Manager – Stephen – 2014-09-16T17:51:38.807

I'm unclear as to what this answer means. What's a PM? – echristopherson – 2013-05-16T04:00:43.123