How to Use Homebrew
Sick and tired of MacPorts and Fink taking an age to install UNIX packages on your Mac OS X box?
Want to install UNIX packages fast, and securely without using
In this screencast we'll show you how with Homebrew!
What you'll learn
- How to install Homebrew on Snow Leopard
- How to install UNIX packages on OS X
- How to uninstall UNIX packages
- How to search for possible UNIX packages to install
- How to list installed UNIX packages
- How to update Homebrew
Welcome to this screencast on How to Use Homebrew.
In our development career we may be required to install additional software to our system, to aide us in the development process, or perhaps to mirror production as closely as possible, to iron out any kinks before deployment.
OS X doesn't come with a UNIX package manager out-of-the-box like Linux distributions, so traditionally you had two options on a Mac: one was to install MacPorts, and the other was Fink. Both of these required invasive installations, and required
sudo to install packages. Not only that, but it was also very slow when it came to installing packages.
Even if you didn't install packages this way, when using "Official" installers for various tools and servers, they often installed to system paths which can get reset or altered whenever updates for OS X would come out. You had to reinstall, or figure out which bits of your developer tool chain were missing or broken.
Let's fast-forward to today. Thankfully, there's a much more elegant solution: Homebrew.
Homebrew is package manager created by Max Howell. Homebrew is fast, and doesn't use
sudo to install software packages. It can be comforting to know that you're not giving an installation package full reign of your system.
If you visit the Homebrew website, and click on the "Install Hombrew Today!" link, you'll be sent to the github Wiki page that shows you the installation command you'll need to run.
Copy and paste that command into your terminal.
Hit return. Wait a moment, and Homebrew is now installed.
If you don't have Xcode installed aready, you should do so now. Homebrew uses Xcode in some of its formulas to install UNIX packages. Xcode can be downloaded at developer.apple.com/xcode.
Installing Packages with Homebrew
You can run Homebrew from the command line by using the
brew command. Type
brew install, followed by "formula name" of the UNIX package you want to install.
brew install wget installs Wget, and typing
brew install memcached installs Memcached.
As you can see, once the package installs, other information about the package is displayed. We'll show you how to display this info again—don't worry, you're not expected to memorise it!
Uninstalling Homebrew Packages
If you no longer need a UNIX package, all you need to do is type
brew uninstall, followed by the package name.
brew uninstall wget will remove Wget. If you then type
brew list, it shows you all packages installed via Homebrew, and Wget shouldn't be there any more.
Finding Available Packages on Homebrew
If you're not quite sure about the formula name, you can type
brew search followed by the term.
Say we wanted to install PostgreSQL, and di dn't know whether it was
All we'd need to do is type
brew search postgres, and we'll get a list of available formula packages to install. So we'd see that we needed to use
brew install postgresql to install PostgreSQL.
Information on a Package installed by Homebrew
Imagine you installed Postgres a while ago, and forgot to initialize your database. You're not expected to memorise the commands needed to do that, or expected to Google it. All you need to do is type
brew info, followed by the package name.
brew info postgresql, and you'll see all the info you'd need to initialise your databases, start and stop the Postgres daemons, and so forth.
From time to time, Homebrew and it's formulas need to be updated. To update, all you need to type is
brew update. You do need
git installed before running the update command. So if you don't already have git installed, be sure to run
brew install git prior to the update command. Once the update is complete, you'll be set with the latest brew and formulas.
We've really been happy using Homebrew, and we hope you'll give it a try the next time you need to install a UNIX package.
Thanks for watching! Subscribe to our RSS feed, follow us on Twitter, and please leave any questions, comments or suggestions for new screencasts in the comments below. If you like our videos, and think your friends, followers or colleagues would benefit from seeing them, please feel free share via any of the links below the video. We really appreciate your support.
See you next time!