Brewfile: a Gemfile, but for Homebrew

Bundler users define dependencies for Ruby applications in a Gemfile and install those dependencies by running bundle install.

Homebrew users can define dependencies for their OS X operating system with a Brewfile, like this:

# Brewfile
install openssl
# a comment
link --force openssl

To use the Brewfile, tap homebrew/boneyard (one time) to install the command, then run it in a directory with a Brewfile in it:

brew tap homebrew/boneyard
brew bundle

Note that Homebrew will treat lines that start with # as comments. Every other line will be passed to brew. So this:

install openssl
# a comment
link -f openssl

is run as these commands:

brew install openssl
brew link --force openssl


I can think of a few places where a Brewfile would be welcome:

  • In dotfiles, either yours or your company’s. For example, we use it in our excellent dotfiles repo.
  • A setup script for your app (bundle install && brew bundle)
  • A setup script for a new machine. I often forget to install one of them (like rbenv-gem-rehash).

It’s a neat encapsulation for non-programming-language dependencies like phantomjs.

brew brewdle

Homebrew also has an official maintained version of the Brewfile called brewdle that has slightly different syntax:

# Brewfile
brew "openssl"

The file is evaluated as Ruby, and each line starts with brew, followed by the name of a formula in quotes. To use brewdler:

$ brew tap homebrew/brewdler
$ brew brewdle

What’s next

If you found this useful, I recommend reading through the source of the brew bundle command. For more Homebrew tricks, read through our OSX-related posts.