A guest post by Shannon Appelcline, a versatile author and programmer who currently works as the lead iOS developer for Skotos Tech, an online entertainment company. In the past two years, he’s written seven iOS games for them, all based on tabletop releases by popular German designers. The first of these was Reiner Knizia’s Money (2010)—which has also been ported to MacOS—while the most recent was Reiner Knizia’s Modern Art: The Card Game (2011). Shannon’s two most recent books show the breadth of his interests. They are iOS4 in Action (2011), published by Manning Publications, and Designers & Dragons: A History of the Roleplaying Game Industry (2011), published by Mongoose Publishing.
Have you heard about Homebrew, a MaxOS X tool reputed to support developers? Do you want to know more? This post explains the basics!
The Mysteries of Homebrew
MacOS X is built atop the UNIX operating system, which means that it can run thousands of free software packages that have been developed over the last several decades — many of them intended to help programmers, administrators and developers. Unfortunately, it can be quite painful to search for UNIX software on many different sites and to get it working on your home machine. That’s where package management comes in.
Package management tools simplify and centralize the acquisition and installation of software on your computer system. In fact, they automate it. With a single command, you can install not only the software package that you’re looking for, but also all of its dependencies — which are additional packages required by the software you want! And that’s what Homebrew is: a package management tool that makes it easy to install free UNIX software (and other packages) on your MacOS X machine.
Software developers will find Homebrew especially helpful. It’s built on Ruby on Rails, and so it’s been particularly popular in the Ruby on Rails community. Homebrew can also be used with PHP and with Python. Alternatively, you can grab generally helpful utilities like MySQL or ZSH.
A future post will discuss some of the specific packages that developers may be interested in; this post is instead going to focus mainly on the basics of getting Homebrew to work.
Homebrew is just one of several package management tools for the Mac, with MacPorts being its biggest competitor. MacPorts is older that Homebrew, and some people think it’s more complex; in fact, Homebrew was created specifically to resolve some of MacPorts’ problems. Overall, the choice between the two packages seems to largely be a religious one (see: vi vs EMACS).
With that said, this article presumes that Homebrew is the package management software you’ve opted to try out.
Two Homebrew Caveats
Before we dive fully into Homebrew, two occasionally controversial Homebrew philosophies should be flagged.
First, Homebrew tries to work closely with the existing programs found on the Mac rather than replacing them. On the upside, this means that you’re not going to end up with software that’s out-of-sync with what Apple is doing. On the downside, if you think that some of Apple’s software is out-of-date (say, PHP), then you’re stuck. Fortunately, Homebrew has come up with an alternative method to deal with this problem: the tap. We’ll touch upon taps shortly, and then we’ll discuss how that affects PHP in a future article.
Second, Homebrew runs without using
sudo. Instead, it creates a special version of
/usr/local for installations that it has access to. This has the benefit of keeping your administrative environment simpler and safer. However, it can potentially cause problems if you want to install other things in
/usr/local — though at present that’s only likely to be a issue if you’ve installed things there with common names that clash with what Homebrew is doing.
Caveat Installer. But, if these two caveats don’t scare you off, then read on for how to get Homebrew up and running on your MacOS X machine.
To install Homebrew, you must first install either Xcode or the command line tools for Xcode. This will give you access to the
gcc compiler (and other developer packages). You can easily verify the presence of gcc in Mavericks by simply typing
gcc --version at the Terminal command line. If it gives you a version, you’re set. Otherwise, it will automatically give you the option to install Xcode.
If you need to install Xcode, just click the Install button.
Note: All Homebrew work is down in the MacOS X Terminal, which is available at
Applications > Utilities. The packages you install with Homebrew will generally be Terminal programs too.
Once you’ve installed the command line tools, you can install Homebrew with the following magical incantation. It should all be one line:
$ ruby -e "$(curl -fsSL "
During the setup, you’ll have to
sudo, but then you won’t have to when you install later packages. When you’re done with the setup, you will have installed Homebrew and given it control of
Once you’ve successfully installed Homebrew, you should run
brew doctor to verify your install and ensure that it’s in fighting shape:
$ brew doctor
Your system is ready to brew.
Once you’ve install Homebrew, you can use it to start installing packages on your machine.
Searching for Packages
The easiest way to find packages is through the
brew search command. If you type
brew search, Homebrew will list all of the
formulae (packages) currently available in the standard repository. However, you’ll probably want to use
brew search [search term] in order to find something specific.
If you prefer to look at some more exhaustive lists of Homebrew packages, you can do so online. This search engine will show you listings of packages with explanations:
Alternatively, this web page lists everything in the main repository:
Once you’ve discovered a package that interests you, you can get more information on it with the
brew info [package] command:
$ brew info lynx
lynx: stable 2.8.8
This will tell you where a package is coming from, what version it is, and also what other dependencies will (automatically) be installed with your package.
Once you’ve found a package that you want, you just tell your system to
brew install [package].
Your new package (and any dependencies) will be downloaded, configured, compiled, and installed. Depending on the size of the package, this may take a few minutes of time.
Yes, that is a little brew icon that shows up when your install is done! It’s now ready to run!
Watch for two more posts about using Homebrew. The next one will give some short tips on keeping your Homebrew up-to-date, while the third will discuss some of the most interesting developer packages that you can install through Homebrew.
Look below for some great Mac OS X and Homebrew resources from Safari Books Online.
Not a subscriber? Sign up for a free trial.
Safari Books Online has the content you need
|Macintosh Terminal Pocket Guide will help you learn commands for a variety of tasks, such as killing programs that refuse to quit, renaming a large batch of files in seconds, or running jobs in the background while you do other work. Get started with an easy-to-understand overview of the Terminal and its partner, the shell. Then dive into commands neatly arranged into two dozen categories, including directory operations, file comparisons, and network connections.|
|Mac Hacks helps you dig below the surface to tweak system preferences, mount drives and devices, and generally do things with your system that Apple doesn’t expect you to do. With a little effort, you can make your Mac and its applications perform exactly the way you want them to.|
|OS X Mavericks: The Missing Manual shows you what you get when you cross a Mac with an iPad — OS X 10.9 Mavericks. Its 200 new features include Mac versions of iPad goodies like Maps, iBooks, and iTunes Radio—but not a single page of instructions. Fortunately, David Pogue is back, with the expertise and humor that have made this the #1 bestselling Mac book for over 11 years straight.|