Package Management with Homebrew

I've spent my Labor Day weekend completely nerding out over Homebrew, a new package-management system for OS X 10.5 and 10.6. It's especially geared for Snow Leopard (10.6), where it can make 64-bit packages. I was using MacPorts previously, which I liked a lot. Homebrew differs in these ways:

Pros:

  • Heavily optimizes binaries and libraries
  • Easy to write your own formulas for packages
  • Super-hackable
  • GoboLinux-style package naming (like /usr/local/Cellar/Ruby/1.9.1/bin,lib,etc)
  • Easy to manipulate everything using normal Unix tools

Cons:

  • No dependency management
  • Few packages right now
  • No variants
  • Homebrew's Ruby coding style is special

"No dependency management" isn't as much of a con as you'd think. It can be painful, to be sure, but it prevents the MacPorts way of installing everything under the sun that you could possibly rely on, even if it already exists in OS X. Instead of creating a self-sufficient environment, Homebrew creates an environment that relies on what OS X already provides. Depending on your preferences, this could be good or bad.

Homebrew is just a set of Ruby programs, which makes it easy for me to work with. It's in a git repository, so I've forked it to customize for my own tastes. Each package has a formula -- a Ruby class -- to define the installation steps. This helps with the issue of having no named variants. If you want the package to be compiled differently, change it in your fork. The same applies to non-existent packages: it's easy to make your own and add them to your fork. Here's an example package for zsh:

class Zsh <Formula
  @url='http://downloads.sourceforge.net/project/zsh/zsh-dev/4.3.10/zsh-4.3.10.tar.gz'
  @homepage='http://www.zsh.org/'
  @md5='031efc8c8efb9778ffa8afbcd75f0152'

  def install
    system "./configure", "--disable-debug",
                          "--prefix=#{prefix}",
                          "--disable-dependency-tracking"
    system "make install"
  end
  
  # Prevents .la files from getting removed, which was
  # not working for zsh.
  def skip_clean? path
    true
  end
end

I'm enjoying the heck out of Homebrew. It's not quite as convenient as MacPorts yet, but it feels like I'm in complete control of my user environment.

Check out the README for installation and setup.

Published: 07 Sep 2009