Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Homebrew uninstall script
#!/usr/bin/env ruby
#
# CLI tool for locating and removing a Homebrew installation
# http://brew.sh/
#
# Copyright (C) 2014 Stephen C. Benner
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Stephen Benner
# https://github.com/SteveBenner
#
# Contributors:
# - @AaronKulick
#
# NOTE: This script has only been tested and verified to work in OS X 10.9
#
require 'optparse'
require 'fileutils'
require 'open3'
$stdout.sync = true
# Default options
options = {
:quiet => false,
:verbose => true,
:dry_run => false,
:force => false,
:find_path => false
}
optparser = OptionParser.new do |opts|
opts.banner = 'Homebrew uninstaller' + $/
opts.on('-q', '--quiet', 'Quiet mode - suppress output.') do |setting|
options[:quiet] = setting
options[:verbose] = false
end
opts.on('-v', '--verbose', 'Verbose mode - print all operations.') { |setting| options[:verbose] = setting }
opts.on('-d', '--dry', 'Dry run - print results, but perform no actual operations.') do |setting|
options[:dry_run] = setting
end
opts.on('-f', '--force', 'Forces removal of files, bypassing prompt. USE WITH CAUTION!') do |setting|
options[:force] = setting
end
opts.on('-p', '--find-path', 'Output homebrew location if found, then exit.') do |setting|
options[:find_path] = setting
options[:quiet] = true
end
opts.on_tail('-h', '--help', '--usage', 'Display this message.') { puts opts; exit }
opts.on_tail('--version', 'Display script version.') { puts opts.version; exit }
end
optparser.version = '0.1.2'
optparser.summary_width = 16
optparser.parse!
$quiet = options[:quiet] # provides access to option value within methods
# Files installed into the Homebrew repository
BREW_LOCAL_FILES = %w[
.git
Cellar
Library/brew.rb
Library/Homebrew
Library/Aliases
Library/Formula
Library/Contributions
Library/LinkedKegs
]
# Files that Homebrew installs into other system locations
BREW_SYSTEM_FILES = %W[
#{ENV['HOME']}/Library/Caches/Homebrew
#{ENV['HOME']}/Library/Logs/Homebrew
/Library/Caches/Homebrew
]
$files = []
# This function runs given command in a sub-shell, expecting the output to be the
# path of a Homebrew installation. If given a block, it passes the shell output to
# the block for processing, using the return value of the block as the new path.
# Known Homebrew files are then scanned for and added to the file list. Then the
# directory is tested for a Homebrew installation, and the git index is added if
# a valid repo is found. The function won't run once a Homebrew installation is
# found, but it will accumulate untracked Homebrew files each invocation.
#
# @param [String] cmd A shell command to run
# @param [String] error_msg Message to print if command fails
#
def locate_brew_path(cmd, error_msg = 'check homebrew installation and PATH.')
return if $brew_location # stop testing if we find a valid Homebrew installation
puts "Searching for homewbrew installation using '#{cmd}'..." unless $quiet
# Run given shell command along with any code passed-in via block
path = `#{cmd}`.chomp
path = yield(path) if block_given? # pass command output to your own fancy code block
begin
Dir.chdir(path) do
# Search for known Homebrew files and folders, regardless of git presence
$files += BREW_LOCAL_FILES.select { |file| File.exist? file }.map {|file| File.expand_path file }
$files += Dir.glob('**/{man,bin}/**/brew*')
# Test for Homebrew git repository (use popen3 so we can suppress git error output)
repo_name = Open3.popen3('git remote -v') do |stdin, stdout, stderr|
stderr.close
stdout.read
end
if repo_name =~ /homebrew.git|Homebrew/
$brew_location = path
else
return
end
end
rescue StandardError # on normal errors, continue program
return
end
end
# Attempt to locate homebrew installation using a command and optional code block
# for processing the command results. Locating a valid path halts searching.
locate_brew_path 'brew --prefix'
locate_brew_path('which brew') { |output| File.expand_path('../..', output) }
locate_brew_path('command -v brew') { |output| File.expand_path('../..', output) }
locate_brew_path 'brew --prefix' do |output|
output = output.split($/).first
File.expand_path('../..', output)
end
# Found Homebrew installation
if $brew_location
if options[:find_path]
puts $brew_location
exit
end
unless options[:quiet]
puts "Homebrew found at: #{$brew_location}"
begin # record kegs and taps for later output
brewed = `brew list`
tapped = `brew tap`
rescue StandardError
end
end
# Collect files indexed by git
begin
Dir.chdir($brew_location) do
# Update file list (use popen3 so we can suppress git error output)
Open3.popen3('git checkout master') { |stdin, stdout, stderr| stderr.close }
$files += `git ls-files`.split.map {|file| File.expand_path file }
end
rescue StandardError => e
puts e # Report any errors, but continue the script and collect any last files
end
end
# Collect any files Homebrew may have installed throughout our system
$files += BREW_SYSTEM_FILES.select { |file| File.exist? file }
abort 'Failed to locate any homebrew files!' if $files.empty?
# DESTROY! DESTROY! DESTROY!
unless options[:force]
print "Delete #{$files.count} files? "
abort unless gets.rstrip =~ /y|yes/i
end
rm =
if options[:dry_run]
lambda { |entry| puts "deleting #{entry}" unless options[:quiet] }
else
lambda { |entry| FileUtils.rm_rf(entry, :verbose => options[:verbose]) }
end
puts 'Deleting files...' unless options[:quiet]
$files.each(&rm)
# Print a list of formulae and kegs that were removed as part of the uninstall process
if brewed
puts
puts 'The following previously installed formulae were removed:'
puts brewed
end
if tapped
puts
puts 'The following previously tapped kegs were removed:'
puts tapped
end
@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Apr 24, 2014

Instructions:

  • Firstly, the script naturally requires execution privileges. You can make it executable for your user with: chmod u+x unbrew.rb.
  • You can run the script by executing it normally on the command line, which means either using the absolute path, e.g. /Users/username/unbrew.rb, or if the file is in your current working directory: ./unbrew.rb.
  • I prefer to run this like any other binary program in unix, meaning I use a command such as: ln -s <path-to-script> /usr/local/bin/unbrew to symbolically link it into my executables directory. Now I can just call unbrew in the shell, like a normal command.
  • I recommend running the script with sudo in case there are any permissions irregularities present in your system, which can easily happen. This is just my preference though—it works fine without sudo.
@best-coupon-codes

This comment has been minimized.

Copy link

commented Jun 9, 2014

Hi Steve! Thanks for this script. When I use it I am getting:

$ sudo ./unbrew.rb
Searching for homewbrew installation using 'brew --prefix'...
./unbrew.rb:80:in ``': No such file or directory - brew (Errno::ENOENT)
    from ./unbrew.rb:80:in `locate_brew_path'
    from ./unbrew.rb:106:in `<main>'

This is how supposed to be? It look like he stops at that point.

@ofalbertm

This comment has been minimized.

Copy link

commented Jun 9, 2014

Thanks Steve!
Works fine.
Was able to uninstall
and then successfully install again.

@samstav

This comment has been minimized.

Copy link

commented Jun 16, 2014

Excellent. Thank you.

@cauerego

This comment has been minimized.

Copy link

commented Jun 17, 2014

Worked fine for me, but I also had to resolve one issue unaddressed here...

I've tried removing macports, but it still left bad permissions behind. In my case, the problem was this, every time:

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
Password:
==> Downloading and installing Homebrew...
remote: Counting objects: 179487, done.
remote: Compressing objects: 100% (49680/49680), done.
remote: Total 179487 (delta 128693), reused 179418 (delta 128645)
Receiving objects: 100% (179487/179487), 35.45 MiB | 373.00 KiB/s, done.
Resolving deltas: 100% (128693/128693), done.
From https://github.com/Homebrew/homebrew
 * [new branch]      master     -> origin/master
error: unable to unlink old 'Library/Contributions/brew_bash_completion.sh' (Permission denied)
error: unable to unlink old 'Library/Contributions/brew_fish_completion.fish' (Permission denied)
error: unable to unlink old 'Library/Contributions/brew_zsh_completion.zsh' (Permission denied)
fatal: cannot create directory at 'Library/Contributions/cmd': Permission denied
Failed during: git reset --hard origin/master

So I went to /usr/local and used chown -R caue Library to set the permission properly. Maybe this can give you a hint on many places you should look for folders to have proper permission after cleaning up Homebrew... Or maybe this should be addressed on the installation script. I'm not sure. How about both? :P

@AaronKulick

This comment has been minimized.

Copy link

commented Jun 17, 2014

Instead of relying on which, why not consider using builtin command -v brew?

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Jun 25, 2014

@reactorIO: I’m not sure why the script broke for you; did you modify it before running? Did you use any options/flags? I can’t tell what’s wrong from just the output you pasted, but of course it isn’t supposed to ‘hang’ like that. It seems an IOError is being thrown, but the script is actually supposed to catch all exceptions based on StandardError and just keep running if it can’t find the homebrew location… It looks like the execution of the shell command in backticks is returning an unexpected result, so this is probably due to your system having an odd configuration, or you messed with the script itself. I’d be happy to help you figure it out if you can supply more info. Try running the commands used by the script yourself, in a terminal, and see what that results in.

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Jun 25, 2014

@cauerego Are you saying that after running the unbrew script, there were still homebrew files leftover? If working properly, the script should remove all of the ‘old’ files, and there shouldn’t be any interactions with other software; it should be totally clean so you don’t have to remove anything manually. I intentionally avoid messing with permissions unless truly necessary--my philosophy is to be as unobtrusive as possible, especially with such a tricky subject. There are many ways to configure your system, and depending on how permissions are set up, it may require the use of sudo before running the script, which is why I recommend doing that in my initial comment.

In the open-source world of Unix/POSIX we’ve gone a long way towards making it easy for software to be interoperable, but unfortunately the freedom and customizability of our systems means it’s still a massive headache much of the time. It takes a lot of knowledge to ‘master’ unix development I think, but if we encourage the propagation of best-practices and focus on constant maintenance and documentation of our systems it will just keep getting easier. For instance, with resources like stackoverflow, it’s incredibly easy for new users (like myself) to discover important conventions and info, such as the fact /usr/local is a special directory left up to the user to manage—Mac OS doesn’t touch it, and as software-builders we wouldn’t want to end up intruding either. So really, what is deemed as ‘proper’ permissions should be left to the user, which is why we invented forking and such.

I am sure that the best philosophy for design of software tools is based on being unopinionated as much as possible, and this is more vital the ‘lower’ something operates in the system. Homebrew captures this with a rare elegance that makes it simple to use and powerful at the same time; that’s why I’m so interested in extending it’s capabilities and supporting it’s usage/adoption. We are going a long way with community work on Homebrew. I don’t contribute directly to the project, (yet) but I do want to work on extending the capabilities of Homebrew at some point soon. Addressing your comment, I hope you can see why Homebrew doesn’t change permissions when installing like you suggest, and I wouldn't change that for an uninstaller tool either.

I encourage people to check out this stack exchange thread as it has a lot of very good discussion and information about Homebrew and permissions. I use the command mentioned by the poster on occasion myself to set things straight.

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Jun 25, 2014

@AaronKulick I’ve never heard of that command before, and after googling a bit it seems to me still quite vague. But I intended the script to be as convenient and invisible to the user as possible, (it should just _work_) so I added your suggestion and attribution. The more code that contributes to a better uninstaller, the better it does it’s job.

P.S. I would be interested to know any merits or reasoning behind using the command -v brew as you suggest, just because I’m still not sure exactly wherein the differences lies in using which brew.

@GrimaceVladimir

This comment has been minimized.

Copy link

commented Jun 26, 2014

Hey Steve. I get this when running your initial command ./unbrew.rb: command not found . Any ideas on how I can solve this? And is it harder to uninstall homebrew or macports is harder?

@neversleepz

This comment has been minimized.

Copy link

commented Jul 13, 2014

@GrimaceVladimir You'll need to give execute permissions to the script. eg chmod a+x unbrew.rb
@Steve great script. worked well. Liked the verbose and dry run modes.

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Jul 25, 2014

Hi guys

So I added a new feature (well, two, technically) in which the script will output a list of all formulas and kegs you had installed/tapped, after removing them. I thought it was a pretty clever addition, seeing as the script really does its best to wipe your system of all things Homebrew, possibly leaving you wondering what he hell you had installed previously! I'm in the habit of doing things like brew list > ~/Downloads/brews.txt in case of uninstalling package managers and such, but now people don’t need to worry about that. I tested it out, and this feature seems to work just fine with everything.

The other thing I added was just versioning, and an option to print the script version... I recently discovered that this is a builtin ability of OptionParser, which is cool, and fit with my desire to develop it further. I started maintaining a change log and tags already, and it had me thinking... I’ll probably hit up the maintainers at some point and see if they are interested in making a better official uninstaller, as what we have on the Homebrew wiki is pretty sad...

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Jul 25, 2014

@GrimaceVladimir I edited my initial comment with more clear instructions for everyone, hope that helps. Also, I haven’t used MacPorts but from what I hear, it’s much more difficult to work with in general.

@schiff

This comment has been minimized.

Copy link

commented Aug 11, 2014

Works like a charm. Thank you so much for your time. Removing Homebrew can definitely be a pain.

@bijancamp

This comment has been minimized.

Copy link

commented Jan 1, 2015

Thanks for helping a playa out. I found this from your AskDifferent post. It helped me debug a problem with one of my packages!

@ataipale

This comment has been minimized.

Copy link

commented Feb 11, 2015

Hi Steve,

I ran your script under sudo permissions and had the same problem as @cauerego .Thoughts on the best way to fix it other than permissions alterations?

@sdegutis

This comment has been minimized.

Copy link

commented Feb 13, 2015

lol @SteveBenner why not just forego your whole Instructions: section and just note that it can be run with sudo ruby unbrew.rb?

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Feb 16, 2015

@ataipale Unfortunately, because the issues you and @cauerego experienced are rooted (haha!) in _permissions_, one of the most convoluted and complicated aspects of Unix, often there is no easy solution except attaining a deeper understanding of how they work, which is why I pointed towards this highly informative stackexchange thread as the ultimate answer to him.

I regrettably note that my response to @cauerego became a wall of text that probably came off as rambling… The fact is, this is a very complex and murky topic, which can be seen by how hotly the opinions in the thread are debated. But there you will also find far more than I can provide you, so really check it out. It’s very easy to misunderstand what’s going on otherwise; @cauerego, for example, mentions he set permissions with chown, but that command changes the file owner, a completely different operation.

As a reminder, this script only does ONE thing affecting your system, and that is remove Homebrew. Even when run with sudo, it’s not altering any permissions whatsoever.

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Feb 16, 2015

@sdegutis Such CLI knowledge might seem obvious to us now, but coming from a background of being completely self-taught, I always found huge appreciation in those who went the extra mile to illuminate the science behind it all. Those four particular points are tidbits I consider highly useful and if it helps just one person then I think it’s worth it 😎

@gigaimage

This comment has been minimized.

Copy link

commented Feb 24, 2015

I followed the instructions. Ran the script. It worked for me - Mac 10.10.2 Y

It ID 3493 files to be removed... I hope they were Homebrew install files only! :)

Thanks for a clear and one shot solution to overly debated/questioned prior solution

Update: Reinstall worked without any problem..

@giogadi

This comment has been minimized.

Copy link

commented Mar 18, 2015

Thanks for writing this.

When I ran this, however, it didn't actually remove any of the files installed by Homebrew. That is, it removed anything directly Homebrew related (Cellar, the config files) but left everything else that I installed using homebrew (bin, include, share, ...). Is this on purpose?

@jproberts14

This comment has been minimized.

Copy link

commented Mar 26, 2015

Thanks for creating this script Steve. The script worked great on my Mac Pro but when I tried to run it on my MacBook Pro, it's hanging right after it starts searching for the homebrew files. These are the 4 lines that I see before it hangs:

Searching for homebrew installation using 'brew --prefix'...
Searching for homebrew installation using 'which brew'...
Searching for homebrew installation using 'command -v brew'...
Searching for homebrew installation using 'brew --prefix'...

After a while, I got a message that said Delete 27 files? I said yes and it proceeded to delete those files. When I check out my /usr/local folder, some of the files are still there. When I compare the folder to the one on the Mac Pro, the files remaining are:

.gitignore
.yardopts
brew (in the bin folder)
codeofconduct.md
contributing.md
rubocop.yml (in Library folder - the Library also has the folders 3.2.6, 4.2, 4.3 which aren't on the Mac Pro)
License.txt
Readme.md
Homebrew folder under the Share folder (has 41 items in it) (the Homebrew folder is there on the MacPro but it's empty)
There is also a brew.1 file in the Man/Man1 folder as well
supporters.md

When I ran the script on the Mac Pro, it said it had found over 3,000 files.

Should I try to run the script again or is there another solution you can think of?

Thanks Steve!

Edit: I forgot to mention that I tried running it without sudo first, then ran it with sudo the second time.

@jproberts14

This comment has been minimized.

Copy link

commented Mar 28, 2015

Additional information regarding my uninstall issue. I remembered that the only difference in the installation between the mac pro and the macbook pro was xCode. On the mac pro, I had it installed via the command line interface. On the macbook pro, I went through the app store. Not sure if that has any relevance or not though.

@bsl787

This comment has been minimized.

Copy link

commented Apr 1, 2015

Hello. I am very new. I had to re-install my Yosemite OS (iMac) because of a corrupted user profile. Homebrew insists on installing (trying) software to the corrupted user profile. I think I need to remove Homebrew. Looking at the directories in /usr/local/Cellar/, I notice some that appear to be ones I'd like to keep (python, octave, postgresql). If I run your script, do I lose these directories and re-install? How do I know which are the ones that Homebrew installed itself? For reference, permissions are root, group = wheel. Thank you.

BSL

@SteveBenner

This comment has been minimized.

Copy link
Owner Author

commented Apr 8, 2015

@giogadi The directories you've mentioned, (bin/, include/, share/), among a few others, are created merely as a Unix convention (read more here) and they are used by many different programs. As it happens, Homebrew does not actually install anything in these folders—it is completely self-contained, relying on symbolic links from the original files to these locations, a very clean solution. When you use the uninstaller script, the symlinks should be removed along with Homebrew’s files. Anything remaining must have been installed by the user at some point, because the /usr/local/ directory itself is empty by default (and consequently safe to remove entirely!).

@jproberts14 I’m not sure how much help I can be to your situation, without more specific constraints to work with. Your Homebrew installation is definitely buggered—I would recommend deleting the entire contents of /usr/local/ and starting fresh. The fact your installation couldn’t be located using the first 3 commands indicates Homebrew wasn’t installed correctly in the first place, or that your shell environment is improperly configured. Any any rate, the ‘hanging’ is my last-ditch attempt to scrounge up Homebrew files in cases just like this… It’s far from spotless so again I recommend starting from scratch.

Bear in mind the script comes with several helpful options designed specifically with troubleshooting in mind. They are all inter-compatible. For instance, if you want to write a list of all the files potentially deleted by the script to a text file, you could run unbrew -d -f > results.txt which combines the ‘dry-run’ option (also known as no-op) with forced mode. _This is very cool._

As per convention, the script options and usage can be viewed by running it with -h or --help
@Roboji

This comment has been minimized.

Copy link

commented Aug 13, 2015

Hi Steve,
I experience the same problem as stated before by famousky.

$ sudo ./unbrew.rb
Searching for homewbrew installation using 'brew --prefix'...
./unbrew.rb:80:in ``': No such file or directory - brew (Errno::ENOENT)
from ./unbrew.rb:80:inlocate_brew_path' from ./unbrew.rb:106:in

'

I definitely have homebrew installed, so what am/can I do now??
Thanks!

@gethubd

This comment has been minimized.

Copy link

commented Aug 26, 2015

Hi Steve - thanks for the script. Just FYI I tried this on mac os x 10.6.8 and had the same problem as jproberts14. My guess is that the homebrew installs to different locations on 10.6 and the script doesn't see all of the files (however I am a complete novice so it's entirely just a guess). Your script didn't actually 'hang' as stated by jproberts14 - I was watching the activity in the activity monitor and it said ruby was very busy (with varying levels of cpu and disk activity) presumably looking for files. This took about 5 minutes before coming up with the "Delete 27 files ?" response. Most of the files it found were in the /local/ dir though it missed many others also in there.
I manually deleted all the remaining files in usr/local/ except for a few which were much older than the homebrew install.
Any tips on finding any other files to delete ( and I suspect there a a couple of thousand lurking around somewhere as between your script and manual deletion I think we only removed about 100-200), would be appreciated.
Thanks again for sharing.

@claudia1204

This comment has been minimized.

Copy link

commented Sep 27, 2015

Hi Steve,
I experienced the same problem.

sudo ./unbrew.rb

result:
Searching for homewbrew installation using 'brew --prefix'...
./unbrew.rb:105:in ``': No such file or directory - brew (Errno::ENOENT)
from ./unbrew.rb:105:inlocate_brew_path' from ./unbrew.rb:131:in

'

when I installed homebrew i quitted by control+C because of network problem. I do not know what should I do now....
Thanks!

@Roboji
use rm -rf /usr/local/Cellar /usr/local/.git I resolved problems, thanks~

@marktmiller

This comment has been minimized.

Copy link

commented Oct 29, 2015

I tried Homebrew's uninstall command, which just messed up my installation. I couldn't use any of the packages afterward, nor could I reinstall them. They need to fix that! Your script cleaned out what needed to be cleaned, and made it so I could reinstall Homebrew from scratch. Thanks so much for posting this!

@lloeki

This comment has been minimized.

Copy link

commented Apr 11, 2016

Watch out, this script doesn't stop potentially running services beforehand, something to the effect of:

for d in {/Users/`whoami`,}/Library/Launch{Agents,Daemons}/homebrew.mxcl.*.plist; do launchctl unload $d; done
@phanhoangphuong

This comment has been minimized.

Copy link

commented Jul 18, 2016

Thank you very much. It works very well.

@lewismc

This comment has been minimized.

Copy link

commented Sep 20, 2016

@SteveBenner, if you have homebrew or homebrew-core already checked out to /usr/local then the script will fail, incorrectly thinking that you have Homebrew installed as oppose to just checked out locally into /usr/local.
After pruning both homebrew and homebrew-core from /usr/local and using your script it all went well thanks.

@cmfrtblynmb728

This comment has been minimized.

Copy link

commented Sep 22, 2016

@SteveBenner I ran the script but it is stuck at the message "Searching for homewbrew installation using 'brew --prefix'..." for over an hour. Thanks!

Searching for homewbrew installation using 'brew --prefix'...
Searching for homewbrew installation using 'which brew'...
Searching for homewbrew installation using 'command -v brew'...
Searching for homewbrew installation using 'brew --prefix'...

This is all I see

@kevanchristmas

This comment has been minimized.

Copy link

commented Nov 10, 2016

Thanks for the effort and continued comments/support - worked flawlessly for me

@techartist

This comment has been minimized.

Copy link

commented Nov 26, 2016

@SteveBenner I am having the same issues as @cmfrtblynmb728. Any suggestions? No options were given on the command line I just ran ./unbrew.rb.

@anthonyrollett

This comment has been minimized.

Copy link

commented Dec 11, 2016

Likewise, running on 10.10, needed to clear it out, seems to have worked exactly as intended. Much appreciated.

@anthonyrollett

This comment has been minimized.

Copy link

commented Dec 11, 2016

I should have said that I found I had to clear brew out because I still use gfortran from HPC Mac OS X (http://hpc.sourceforge.net) and I needed to reinstall gcc and gfortran (versions 5.1). May not be the best approach these days, so happy to see further comments. Thanks again.

@binchuri

This comment has been minimized.

Copy link

commented Jun 29, 2019

Hello,
I was trying to use your script to uninstall Homebrew from Mac OSX Mojave (10.14.5) as it was unable to find the latest Xcode and Command Line Tools. However, it seems that the script is not actually deleting the files, they remain even after I run it. I am attaching the terminal output for your reference:

Apple$ ./unbrew.rb 
Searching for homewbrew installation using 'brew --prefix'...
Searching for homewbrew installation using 'which brew'...
Searching for homewbrew installation using 'command -v brew'...
Searching for homewbrew installation using 'brew --prefix'...
Delete 16 files? y
Deleting files...
rm -rf share/man/man1/brew-cask.1
rm -rf share/man/man1/brew.1
rm -rf bin/brew
rm -rf Homebrew/bin/brew
rm -rf share/man/man1/brew-cask.1
rm -rf share/man/man1/brew.1
rm -rf bin/brew
rm -rf Homebrew/bin/brew
rm -rf share/man/man1/brew-cask.1
rm -rf share/man/man1/brew.1
rm -rf bin/brew
rm -rf Homebrew/bin/brew
rm -rf usr/local/share/man/man1/brew-cask.1
rm -rf usr/local/share/man/man1/brew.1
rm -rf usr/local/bin/brew
rm -rf usr/local/Homebrew/bin/brew
Apples-MacBook-Air:unbrew Apple$ cd 
Apples-MacBook-Air:~ Apple$ cd /usr/l
lib/     libexec/ local/   
Apples-MacBook-Air:~ Apple$ cd /usr/l
lib/     libexec/ local/   
Apples-MacBook-Air:~ Apple$ cd /usr/local/
Apples-MacBook-Air:local Apple$ ls
Caskroom	etc		lib		sbin		var
Homebrew	gfortran	opt		share
bin		include		remotedesktop	texlive

Can you please advise what I should do? I also used unbrew.rb with sudo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.