Battle of the Package Managers!

June 10, 2011 by . 0 comments

What is a package manager?

A package manager is a software tool that is used to install other software. This software is often referred to as “packages,” hence the name. Package managers exist on many Linux or UNIX-like operating systems. Before package managers existed, people were stuck with installing software from source. This presented two main problems:

  1. In order to update the software, you had to download the source for every program that was out of date, and then compile and install it again.
  2. If a program had any dependencies, you’d have to hunt down that dependency, and then that dependency’s dependencies, and so on, eventually creating something called “dependency hell.”

Package managers were created to solve these problems. With them, you can run a command to install, uninstall, search for, or update packages. Many Linux and UNIX-like operating systems have package managers built in. For instance, Ubuntu has aptitude and FreeBSD has the ports system. Mac OS X, however, does not have any built in package manager. This lack of a built in package manager has prompted people to create their own. There are two popular package mangers for OS X, Homebrew and MacPorts, each with their own strengths and weaknesses. In this post, I will put each of those package mangers to the test, and let you decide which you think is better.

First up, MacPorts!

MacPorts is one of the first package managers created for Mac OS X. It was created in 2002 and is still actively maintained. It is based off of FreeBSD’s port system, and behaves much like it. MacPorts can be downloaded from its homepage and has versions available for Tiger, Leopard, and Snow Leopard. When you install it, you get a graphical installer like such:

MacPorts installer

This is the last graphical part of MacPorts we’ll ever see. It’s all command line after this.

The MacPorts installer gives you the port command that you use for installing stuff. Let’s put that command through its paces.

Installing software with MacPorts

The main feature of any package manager is its ability to install packages, and every single one of them can. MacPorts is no exception. Installing software is pretty simple. I’ll install something (let’s say mutt) through MacPorts and let’s see how it goes. First I’ll run this command to install mutt (which is a command-line email client, by the way)

$ sudo port install mutt
Of course, I will be prompted for my password, and after this I will get the following output:
--->  Computing dependencies for mutt
--->  Fetching mutt
--->  Attempting to fetch mutt-1.4.2.3.tar.gz from http://ykf.ca.distfiles.macports.org/MacPorts/mpdistfiles/mutt
--->  Verifying checksum(s) for mutt
--->  Extracting mutt
--->  Configuring mutt
--->  Building mutt
--->  Staging mutt into destroot
--->  Installing mutt @1.4.2.3_1
--->  Activating mutt @1.4.2.3_1
--->  Cleaning mutt
All of this took about a minute and twenty seconds, pretty fast. But if I were installing something that was a bigger program, like vim, it would have taken somewhere around half an hour (trust me, I’ve tried). After all of this I have the mutt program installed and ready to use. Now let’s say I don’t like mutt and want to get rid of it.

Uninstalling software with MacPorts

So I’ve grown tired with mutt and don’t want it anymore. It’s time to uninstall it. Doing this is quite simple, just like installing programs. To uninstall mutt I’d run this command:

$ sudo port uninstall mutt
After this I’d get the output:
--->  Deactivating mutt @1.4.2.3_1
--->  Cleaning mutt
--->  Uninstalling mutt @1.4.2.3_1
--->  Cleaning mutt
Much less output than what I got with the install command. This all took about half a second, pretty darn quick. Mutt is now gone. Many other commands are available with MacPorts, all of which can be listed by doing:
$ port help

Next, Homebrew!

Homebrew is much newer than MacPorts and was started as early as 2009. However, Homebrew is just as, if not more popular than, MacPorts. Very many people (myself included) prefer Homebrew because it is newer, and faster than MacPorts. The fact that Homebrew is newer than MacPorts also means that it doesn’t have as much software available as MacPorts, only about (at the time of writing) 1,000 packages compared to MacPorts’s 8,000. Homebrew is installed without any sort of graphical component. And install instructions are on the Homebrew homepage. To use Homebrew, you need to have Ruby installed. Ruby is a programming language and I won’t get into it much in this post (that’s something for the SO blog). To install Homebrew, you run the following command:

ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
You can install Homebrew anywhere you want, however /usr/local is the preferred location, and the one that installation script uses. After installing it, you can do the various package managing functions with the brew command.

Installing software with Homebrew

Homebrew, just like MacPorts and every other package manager, has the ability to install packages. However, unlike MacPorts, you don’t need root permissions (which is what the sudo command was for in the MacPorts examples) to manage your packages. Let’s say I want to install mutt, but with Homebrew this time. I’d run the command

$ brew install mutt
This is nearly identical to the way MacPorts does installations, except for the omission of the sudo part and with Homebrew’s method, and brew replaces port used in the MacPorts examples. Doing this will produce the following output:
==> Downloading ftp://ftp.mutt.org/mutt/devel/mutt-1.5.20.tar.gz

################################################################## 100.0%

==> Downloading patches

################################################################## 100.0%

==> Patching patching file buffy.c ==> ./configure --disable-dependency-tracking --disable-warnings --prefix=/usr/local/Cellar/mutt/1.5 ==> make install ln: ./mutt.mo: Permission denied Error: The linking step did not complete successfully The formula built, but is not symlinked into /usr/local You can try again using `brew link mutt' Error: Could not create symlink /usr/local/share/locale/bg/LC_MESSAGES/mutt.mo. Check that you have permssions on /usr/local/share/locale/bg/LC_MESSAGES ==> Summary /usr/local/Cellar/mutt/1.5.20: 111 files, 6.6M, built in 48 seconds

All this took a little over a minute, the 48 seconds reported is the time it took to build the software, and doesn’t include the time taken to download it. Those errors aren’t that important, and won’t affect mutt much at all. Well, I’m tired of mutt now, and I’m going to uninstall it.

Uninstalling software with Homebrew

Now that I don’t want mutt anymore, I’m going to uninstall it.

$ brew uninstall mutt
After I do that, I’ll be presented with this output.
Uninstalling /usr/local/Cellar/mutt/1.5.20...
Much less than I got when uninstalling mutt via MacPorts. It took a bit more time than MacPorts did, but is still under a second.

Wrap up

As you can see, both of these package mangers have their own ways of doing things, and both are equally viable options if you’re choosing what package manager to use on Mac OS X. Of course, if you don’t actually need a package manager, odds are you shouldn’t go through the trouble of installing one.

Subscribe to comments with RSS.

Comments have been closed for this post