Last Updated: May 03, 2018
· pstadler

Homebrew's new feature: Brewfiles

A great new feature has found its way into Homebrew: Brewfiles.

# create a Brewfile
$ touch Brewfile

# add the formulas you can't live without
$ echo 'install ack' >> Brewfile
$ echo 'install vim --override-system-vi' >> Brewfile

# you can also tap into repositories
$ echo 'tap homebrew/versions' >> Brewfile

# `bundle` simply prefixes every line in the Brewfile with "brew"
$ echo 'update' >> Brewfile # runs `brew update`
$ echo 'doctor' >> Brewfile # runs `brew doctor`
# ...

# this will process the Brewfile in the current directory
$ brew bundle

# or you can point to a specific one
$ brew bundle ~/GitHub/dotfiles/Brewfile

This is not only perfect for your own dotfiles, but also for defining project specific package dependencies (e.g. gettext, imagemagick) — ease your teammates' pain with a freshly brewed Brewfile!

Please get in touch with me if you have any questions or suggestions related to this topic. You can find me on Twitter and GitHub.

22 Responses
Add your response


Awesome, I'm glad you found a use for my contribution to Homebrew! You can also use directory-specific bundling with:

brew bundle ~/GitHub/dotfiles/

and Homebrew will automatically grab your Brewfile. Let me know if you have any ideas for future features, I'd love to hear your input.

over 1 year ago ·

Great work @christianbundy.

over 1 year ago ·

this is great feature :D thanks

over 1 year ago ·

Really cool, needs help and man coverage though... :-)

over 1 year ago ·

At least one user of homebrew-cask was hoping for a supporting Caskfile. If any one is of a similar opinion I offer the response I gave him/her.

The Brewfile handles casks natively. Here is a fragment from my own Brewfile.

# casks
install brew-cask
tap phinze/cask
cask install antirsi
over 1 year ago ·

The correct order would be

tap phinze/cask
install brew-cask
over 1 year ago ·

Can you have multiple Brewfiles in a single directory for compartmentalized installs?
Examples: brew bundle NodeBrewfile or brew bundle RubyBrewfile

over 1 year ago ·

I heard you like bundles, so let's bundle bundles.

$ echo 'install ruby' > Brewfile-ruby
$ echo 'bundle Brewfile-ruby' > Brewfile
$ brew bundle
over 1 year ago ·

BOOM. @PStadler, I owe you a sixer.

over 1 year ago ·

Hey Patrick, I created a generator for custom Brewfiles and Caskfiles. If you have a second, any feedback would be really appreciated!

over 1 year ago ·

And @kevinsuttle, you can absolutely use any filename you want for separate files. If you use Brewfile, you don't have to specify the filename, that's about it.

over 1 year ago ·

I'm SOOOOO glad you named it Brewfile because otherwise I'd have no idea that file was a file. Seriously, the proliferation of config files named this way is a bad thing and confuses the heck out of syntax-aware editors and other software.

over 1 year ago ·

This is great: I'm already using bundler as my (almost) one stop shop to provision new workstations... this is making it even easier.

an idea (unless it's already built in): what about letting brew bundle accept a url?

  1. brew bundle
  2. go get a coffee
  3. start working
over 1 year ago ·

That's a good idea @bru. I I wonder if you could just curl it?

zsh <(curl -s$USER/$REPO/master/Brewfile)

over 1 year ago ·

This was working great for me.. but something seems to have changed recently, and it's erroring out now:

mwarkentin@Michaels-MacBook-Pro ~  $ brew bundle
Warning: bash-completion-1.3 already installed
Error: git-1.8.5 already installed
To install this version, first `brew unlink git'
Error: Command failed: L3:brew install git
over 1 year ago ·

@mwarkentin it seems that you have a problem with your git installation. try to upgrade (or unlink/link) manually.

over 1 year ago ·

@pstadler I thought it might be a problem specific to git, but I commented that line out, and the next one blew up the same way. Commented that one out, and the next one blew up..

$ brew bundle
Warning: bash-completion-1.3 already installed
Error: hub-1.10.6 already installed
To install this version, first `brew unlink hub'
Error: Command failed: L4:brew install hub

$ brew bundle
Warning: bash-completion-1.3 already installed
Error: mackup-0.5.2 already installed
To install this version, first `brew unlink mackup'
Error: Command failed: L5:brew install mackup
over 1 year ago ·

@mwarkentin for me it works fine, I don't know what could possibly be wrong with your Brewfile or Homebrew setup. Can you paste a link here?

over 1 year ago ·

brew bundle doesn't seem to be working for me, I get

$ brew bundle

Error: Unknown command: bundle

But in all other ways brew is working.

over 1 year ago ·

Note that apparently the brew bundle function has been deprecated. See

over 1 year ago ·

Note to readers: the current version of brew bundle is and has a different syntax.

8 months ago ·