If you do development on a Mac and you have a Unix background, you immediately start noticing missing tools and utilities. OS/X doesn’t have an apt-get for package management (or even one of the lousy RPM variants). There are options though. Two of them have been around for quite a while, MacPorts and Fink.
MacPorts is strongly influenced by the BSD ‘ports’ system. Ports are essentially recipes for taking source code and build scripts and making them compile and install on the target operating system. BSD ports organize the recipes and source code into a tree that make adding software easy.
Fink takes a different approach. It’s based around Debian’s packaging tools and apt-get. Fink mainly manages pre-compiled/pre-built applications. So the applications you install using Fink don’t need to be compiled and built on your system.
Between the two of them, MacPorts tends to be the easier solution. Software is more up to date, there are more options, it’s somewhat less intrusive into your system and you get new versions faster when Apple updates OS/X. Ironic when you consider that MacPorts code is compiled on your system while Fink is just downloading binaries.
But MacPorts is still no walk in the park. Even though it’s less intrusive then Fink, it still isn’t a great citizen on OS/X. MacPorts eschews many of the system libraries and software already available in OS/X for other variants. Installing a seemingly simple utility might somehow require a new version of Perl, Python or other set of large software.
Homebrew is a reaction to the complexity of MacPorts. It’s extremely simple. Homebrew appears to be targeted more at individual packages. If you want to pull in the entire world of open source software and want every package, then you’re better off with MacPorts or Fink. But if you’re looking for the occasional tool or utility, Homebrew is for you.
Installation is dead simple:
ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"
That downloads the installer and executes it. Homebrew is based on Ruby and the install script is no exception.
By default Homebrew will try to take over your /usr/local directory. If you’ve already installed anything there (MySQL, etc.) then Homebrew will complain. You can install Homebrew anywhere, but then you’ll have to add that directory to your PATH.
Homebrew also assumes that you’re on a single user system. If that’s not you, then you definitely want to install it to a user-specific location and alter your PATH. But, for most people, the default works just fine.
Once installed, you control Homebrew using the
brew command. You can find packages using
brew search, install them using
brew install and remove them using
Just like any other package manager, Homebrew tracks package dependencies so it will pull
in dependent packages as needed and warn you if you try to uninstall a required package.
The major benefits of Homebrew over MacPorts are simplicity, lack of intrusiveness, and
speed. Homebrew’s recipes try very hard to use the existing tools and libraries in OS/X, so
they tend to build much faster and require fewer dependent libraries. The recipes themselves
are Ruby scripts and are small, simple to understand and easy to create and modify. But,
honestly, if all you want is to install
wget and newer versions of
git and other
open source tools, you’ll never need to look at or understand Homebrew’s recipes. Just
brew install wget,
brew install git and be happy.