Economy of Effort

Twitter LinkedIn GitHub Mail RSS

Stuff I Like That You Should Too: Homebrew For Mac Os X

Mac OS X is a UNIX-based operating system. Apple proudly states that fact whenever they’re pitching OS X.

A lot of people - myself included - like OS X in part because of this fact. I am primarily a Linux user, but for my personal laptop, it’s nice to have a system with all the friendly-out-of-the-box UI trappings of a general consumer product, while still having UNIX at my fingertips.

As a UNIX system, though, Mac OS X has some limiting factors. One of the big ones is that the base system (the set of core tools that make up the OS, named Darwin on the Mac) is not really updatable. Updates come from Apple packaged as part of general operating system updates, but even when Apple does push out updates, it usually not all that up-to-date.

What’s more, the base system doesn’t necessarily come with everything you might want. You can always compile from source, but this is 2011 and package management is a good thing.

There are three main community projects which bring package management for UNIX programs to Mac OS X. They are Fink, MacPorts, and Homebrew.

Of these, my favorite is Homebrew. Homebrew is very light and lean, and ideal for people who just want to install some select packages to augment the Darwin base system.

Both Fink and MacPorts work around Darwin by existing in their own little ecosystems. When installing something that depends on another tool that already exists in Darwin, these package managers tend to install their own copies of those tools instead of using the one already on the system. There are some compatibility advantages to this, but at the same time, there is some confusion when there are multiple copies of libraries and binaries on the same system.

Homebrew takes the other approach, relying on what is provided in the Darwin base system instead of replicating everything itself. It augments Darwin instead of treating it as unreliable and building its own little world.

Homebrew in general “feels” nicer than Fink or MacPorts. In the words of HackerNews commenter dschobel: “There is so much less friction than using macports or fink that I dropped them immediately.” That’s a good way of putting it. Homebrew is just less noisy and less intrusive.

There are other advantages to Homebrew. The scripts (or “formula” in Homebrew nomenclature) for building and installing packages are simple Ruby scripts. Combine the ease of creating formula with the ease of submitting them to the project - as it lives on Github and anyone can contribute with a simple fork and a pull request - and you’ve got an environment for rapid crowdsourced updates.

And update it has. Originally I ran Homebrew with MacPorts as a backup for things that weren’t yet in Homebrew, but the number of such packages has decreased dramatically. The 1587 formulas (as of this writing) in Homebrew is still much less than the 8100 packages in MacPorts or the 12000 packages in Fink, but the important stuff is well represented (and part of the difference is due to Homebrew intentionally excluding things already in Darwin). Still, it is perfectly fine to run more than one package manager to get the package coverage you need.

Homebrew is very easy to use - I won’t bother replicating the explanation of basic commands here, as the home page and the instructions on the wiki cover them nicely. But I will share one little BASH alias that I use. There is no single Homebrew command for upgrading all of your installed Homebrew packages to their latest versions, the way you might in a Debian-based OS with an “apt-get upgrade”. But a handy little BASH alias takes care of that:

[bash]# Homebrew - upgrade all installed packages alias brew-upgrade=‘brew update && brew list | xargs brew install’[/bash]