Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Switching from Macports to Homebrew and getting my development environment back.

I've been a MacPorts user for quite awhile now. There was nothing religious about the decision - on my first day of work I was handed a new Macbook Pro and proceeded to set up a development environment. Tried to, anyway. While I'd been an avid Mac user for most of my life I'd never actually used it for serious web development - I did some small work back in the 90's but that was the days of OS9 and it was all un-Unixy. Long story short: I was a newb at developing on OSX.

Being an Ubuntu user, I was pretty spoiled by apt-get. After about three mintues of trying to compile stuff myself I marched back into my boss's office and asked if there was a package manager for OSX. He directed me to the Mac Ports website and I left extremely relieved. I think I ran across Homebrew at some point but I never explored it further.

For about three months this was satisfactory. MacPorts works well enough but it has a habit of annoying you at certain intersections. The biggest problem, though, was that the rest of the world seemed to be using Homebrew. The writing world, anyway. The biggest disaster came crashing down when I tried to upgrade Ruby to 1.9.

Someone at the company suggested I use rvm to manage my Ruby versions, and I gave it a shot. Here's the thing though - RVM assumes that you're using Homewbrew! In fact, the whole installation process freaks out that its desired Homebrew paths aren't present. Is there a way around this? Probably. But I had neither the time nor the inclination to figure it out.

I gritted my teeth and took the plunge I'd been avoiding for weeks - switching from MacPorts to Homebrew.

This isn't as light of a decision as it might sound. As a developer, I use a ridiculous number of packages to do my work. 368 packages, to be exact. Worse, I was using MacPorts to manage all of my PHP versions and their extensions, not to mention MySQL and all that, aggghhhhh. It wasn't shaping up to be a fun day.

The first thing you need to do is get the Macports packages out of the way. Those packages live in /opt/local and if you try to leave them there all sorts of nasty things will happen. Luckily, getting them out of the way is as easy as this.

sudo mv /opt/local /opt/macports_backup

Don't just blow this directory away. Keep it nice and safe, just in case you need to switch back for some reason.

Next, follow the instructions on http://mxcl.github.com/homebrew/. Its fairly straightforward. At this point though, you're at zero. No packages. In my case, I needed to get back on my feet with PHP as soon as possible. This part isn't as straightforward. Homebrew doesn't ship with nice, neat PHP "recipes" to install.

There is a separate project for these PHP recipes. The link is here but the instructions can be a little mystifying if you're inexperienced and you have to scroll a ways down just to get the setup. Here are my greatly simplified instructions.

brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php

brew install php54

If these three lines don't work you might need to visit the project homepage for additional instructions. In my case they worked without a hitch, probably because I had a fresh Homebrew install.

At this point I had to install a variety of other recipes - mysql in particular. Don't worry, you haven't lost any of your databases! However, you have lost a bunch of other relevant information so you'll need to set that back up. I followed this post here and had a smooth experience.

I'm still in progress with my migration. Why? With ~400 packages that needed to be replaced, I'm only replacing them as I come across them being missing. This is annoying but they're becoming fewer and farther between as I fill them back up.

Oh, and RVM installed without a hitch. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment