afmnbq
Last Updated: May 03, 2018
·
23.47K
· 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

11155

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 ·
11240

Great work @christianbundy.

over 1 year ago ·
11248

this is great feature :D thanks

over 1 year ago ·
11292

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

over 1 year ago ·
11373

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 ·
11375

The correct order would be

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

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

over 1 year ago ·
11381

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 ·
11448

BOOM. @PStadler, I owe you a sixer.

over 1 year ago ·
11612

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

https://github.com/seethroughtrees/homebrew-dotfile-generator

over 1 year ago ·
11613

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 ·
11630

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 ·
11632

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 http://mylogin.github.io/brewfiles/worklaptop
  2. go get a coffee
  3. start working
over 1 year ago ·
11679

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

zsh <(curl -s https://raw.github.com/$USER/$REPO/master/Brewfile)

over 1 year ago ·
11746

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 ·
11776

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

over 1 year ago ·
11789

@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 ·
11790

@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 ·
11792
17107

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 ·
17110

Note that apparently the brew bundle function has been deprecated. See https://github.com/Homebrew/homebrew/issues/32952

over 1 year ago ·
29666

Note to readers: the current version of brew bundle is https://github.com/Homebrew/homebrew-bundle and has a different syntax.

8 months ago ·