afmnbq
Last Updated: June 25, 2016
·
18.71K
· pstadler
Me japan

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.

21 Responses
Add your response

11155
Ayyylmao

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
Img 0719

Great work @christianbundy.

over 1 year ago ·
11248
147186f2f9c90edfc509a0b045038736

this is great feature :D thanks

over 1 year ago ·
11292
1526dcb784188b422544c6344ef223c2

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

over 1 year ago ·
11373
8bf1d396b9a82f9f117ec6c0baf3513a

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
Me japan

The correct order would be

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

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
Me japan

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
Kevin suttle

BOOM. @PStadler, I owe you a sixer.

over 1 year ago ·
11612
0ac0700561455a3d15f90685599d0c6f

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
0ac0700561455a3d15f90685599d0c6f

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
9f0f89bbd9e1ecfbaab6584e429b7a2f

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
06b63e87f4116b2ff55bda7e077796ac

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
Kevin suttle

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
219e6891cd29919cfad373a72eca17dd

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
Me japan

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

over 1 year ago ·
11789
219e6891cd29919cfad373a72eca17dd

@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
Me japan

@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
219e6891cd29919cfad373a72eca17dd
17107
None

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
None

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

over 1 year ago ·