Using MacPorts? You should really think about moving to Homebrew. Why?
- Homebrew installs packages into their own isolated prefixes and then symlinked into /usr/local.
- It uses the libs that are already installed, no need to compile another perl, openssl or x11 and other stuff that can be found on your mac. Don’t waste time and disc space.
- Way better command line user interface
- Homebrew and it’s installation scripts are hosted at Github
- The installation scripts (aka recepies) and Homebrew itself are written in ruby.
Moving from MacPorts to Homebrew sounds a little bit scary. MacPorts has tons of compiled stuff on your system. But you can do this. Trust me
.
First, uninstall MacPorts:
1 | sudo port -f uninstall installed |
Second step: remove everything that is left from MacPorts (check for MySQL and other stuff in /opt/local first) :
1 2 3 4 5 6 7 8 9 10 | sudo rm -rf /opt/local sudo rm -rf /Applications/DarwinPorts sudo rm -rf /Applications/MacPorts sudo rm -rf /Library/LaunchDaemons/org.macports.* sudo rm -rf /Library/Receipts/DarwinPorts*.pkg sudo rm -rf /Library/Receipts/MacPorts*.pkg sudo rm -rf /Library/StartupItems/DarwinPortsStartup sudo rm -rf /Library/Tcl/darwinports1.0 sudo rm -rf /Library/Tcl/macports1.0 sudo rm -rf ~/.macports |
Alternatively you can move those directories to another place and delete them if everything is okay (if you don’t trust your Timemachine
).
After that you should remove the /opt/local/bin from your $PATH.
Now install Homebrew:
1 | ruby -e "$(curl https://raw.github.com/gist/323731/install_homebrew.rb)" |
Yeah! You can now start install packages like wget with
1 | brew install wget |
There is only one little catch: if you have installed ruby gems that depend on libs from your MacPorts directory, you have to recompile them. I had to recompile my rmagick gem because it used the now deleted ImageMagick from MacPorts.

> Homebrew installs packages into their own isolated prefixes and then symlinked into /usr/local.
Macports installs packages into their own isolated prefixes and then hardlinks into /opt/local.
> It uses the libs that are already installed, no need to compile another perl, openssl or x11 and other stuff that can be found on your mac. Don’t waste time and disc space.
Macports used to do that. But moved away. When you have users with different versions of macosx, when you stumble on bugs in apple’s provided ruby, when you want to install python modules without messing in /usr, it is a bad idea to depend on something you cannot control.
> The installation scripts (aka recepies) and Homebrew itself are written in ruby.
Why don’t people love tcl?
Homebrew looks a lot like what macports was 6 years ago and I sometimes regret that time, but I am sure that pkgsrc, fink, portage or macports with their experience have already stumbled on the problems homebrew will face. As such, I won’t yet switch to this new package manager.
You can install your own python, but you don’t have to. And even MacPorts advises you to recompile everything when you upgrade to a newer os version. Even when using MacPorts you can’t guarantee that everything will run fine after an os update. So why should I use that hard path that feels somehow wrong instead of just compile only that packages that I need?
And using git makes it even more comfortable. I am using stuff I know to install the stuff. I even have a history for each change of each recipie and can read the changes directly on github or using the command line. Very simple and slick.
Um, milosh makes some good points, and questions I myself have… but all the cool kids seem to be playing with Homebrew, so I’m checking it out myself (mostly because after updating to Snow Leopard, many of my MacPorts seemed to be hosed).
So here I am in the middle of installing things with Homebrew, and *thankfully* didn’t find your post until after I discovered that with MacPorts, some important *** DATA *** is stored under /opt/local. All my mysql databases live in /opt/local/var/db!
So, for those whose installations are similar to mine, and who follow your steps blindly, they will have just rm -rf’d all their data! Of course, hopefully they have backups! (something else you don’t mention doing).
Still, thanks for the post… as it does give a nice map of other directories that need cleaning after uninstalling MacPorts.
Yes, you were lucky. But that’s just another reason _not_ to use MacPorts
. If you would use the MySQL-Mac-Packages your Database would be in /usr/local/mysql/data .
Why have you installed MySQL using MacPorts in the first place
?
Oh, I don’t know, I’m sure I read something back in 2007 when I set everything up that suggested doing it that way… perhaps the same reason people like Chris Wanstrath suggest installing MySQL via Homebrew instead of using the MySQL-Mac-Packages (http://ozmm.org/posts/homebrew___mysql___snow_leopard.html).
Incidentally, Homebrew installs MySQL databases under /usr/local/var/mysql… and copying my databases over to there from /opt/local/var/db seemed to work fine.
The gisthub-webpage has moved to a secure connection, so the install script is now run by typing:
ruby -e “$(curl https://gist.github.com/raw/323731/install_homebrew.rb)”
Thanks for creating this guide!
[...] So on the recommendation of a friend, I decided to get rid of MacPorts and try out Homebrew. Before nuking MacPorts, I made a short list of the ports I wanted to reinstall with Homebrew. To uninstall I followed these handy isntructions here. [...]
These instructions are dangerous and shouldn’t be followed.
“sudo rm” ing all the macports stuff is a very bad idea. It’s much smarter to carefully move directories to a safe place, in their entirety, so the damage can be undone.
Gabe, you can always go back using your TimeMachine, but I added a comment that you can move the stuff to another directory.
Basically for me it’s : delete everything from this monster as soon as possible
.
The Github “gist” URL has once again changed, no idea why.
Instead of the “gist” subdomain and the “raw” path component, they now use a “raw” subdomain and a “gist” path component, so the correct command is now:
THanks Aaron, I fixed it.
Being late to this party, I nonetheless have to comment.
I too have been with MacPorts from the beginning and while it’s my favorite of the BSD-derived package managers from a users perspective (i.e., figuring out how to make it do what you want), it’s mutated into a monster that’s constantly installing the entire X.org distribution, Perl, Python, and thousands of libfoos, most of which already exist in /usr/lib. Yes, I know, they’re not always compatible and don’t always work. But then again, the opposite is also true. The libraries in /usr/lib do what they do correctly in OS X. The stuff MacPorts installs, not so much. I understand why MacPorts went the direction they did, I just don’t want that on my system and brew seems to do exactly what I’m looking for. I also appreciate that it’s backed into github. I could care less that it’s written in Ruby.
Put away those stone knives and bearskins my friends…