Skip to content

Instantly share code, notes, and snippets.

@ChristopherA
Last active October 22, 2025 20:29
Show Gist options
  • Save ChristopherA/a579274536aab36ea9966f301ff14f3f to your computer and use it in GitHub Desktop.
Save ChristopherA/a579274536aab36ea9966f301ff14f3f to your computer and use it in GitHub Desktop.
Brew Bundle Brewfile Tips

Brew Bundle Tips

Basic Brew Bundle

The most basic command

brew bundle install

Looks for ~/Brewfile and installs its contents

Minimal Essential Bundle

My current minimal Brew on macOS is:

tap "homebrew/core"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "buo/cask-upgrade"
brew "github-keygen"
brew "gnupg"
brew "pinentry-mac"
brew "stow"
brew "mas"
brew "gh"
cask "carbon-copy-cloner"cask "atom"
cask "typora"

Install a specific brewfile

If you want to use a brewfile from a non-standard place.

brew bundle --file=~/.private/Brewfile

Or more specifically:

brew bundle install --file=rs-brew-dump

Creating a Brewfile

You can dump a Brewfile of your current brew/cask/mas entries into your current directory with

brew bundle dump

or to a specific directory and file name.

brew bundle dump --file=~/.private/Brewfile

If a Brewfile already exists, you'll need to do

brew bundle dump --force

Cleaning up to match brewfile

If you want your current system configuration to match your brewfile

brew bundle --force cleanup

My best practices

A key practice is to install EVERYTHING possible using brew, brew cask, or mas. Even things like fonts!

I have two brewfiles currently:

  • One in ~.private which I install right after installing brew and before setting up my basic .ssh and .gnupg files so that I can use GitHub. It is the minimal essential list above. I can install this manually with a script inside .private.

  • My standard in ~/Brewfile is actually a symlink to ~/.dotfiles/mac/Brewfile. I different ~/.dotfiles/ for different environments.

    • My primary Mac is a monster MacBook Pro is really more of a "desktop" for me. It has 64 GB RAM with an 8TB HD. It probably has my largest Brewfile.
    • That being said, it actually doesn't have many development tools in it. Instead, I mostly use VMware instances (mostly macOS but some Debian) for my development images. They use a different ~.dotfiles based Brewfile.
    • My smaller, older MacBook is mostly for travel. It has different set of ~/.dotfiles/ focused on just enough to work remotely. I'm always prepared to restore this Mac from scratch.
    • For a month or so each year, late summer early fall, my old MacBook also will run the latest beta of macOS, allowing me to test not just macOS, but also be prepared for changes to my development environments.
@ChristopherA
Copy link
Author

TODO: brew bundle dump --file=~/brew_bundle_titania_2022-09-18.txt

@ariel-frischer
Copy link

This is super informative and useful. Thank you! 🚀

@NH3R717
Copy link

NH3R717 commented Jun 22, 2023

When restoring a Mac from scratch do you have a way to implement save preferences? There doesn't seem to be a set way to install macOS with these kinds of settings from a config file.

@phette23
Copy link

@NH3R717 defaults might help. You could try to dump settings with defaults read and then apply them when restoring with defaults write. This is essentially what Mathias Bynens' .macos does. The concern that's stopped me from doing this is new settings / state stored in settings messing up a new machine but it should at least be possible.

@thoroc
Copy link

thoroc commented Jul 1, 2024

I cannot see the homebrew/cask. This is the related homebrew from brew bundle dump:

tap "homebrew/autoupdate"
tap "homebrew/bundle"
tap "homebrew/cask-fonts"
tap "homebrew/services"

@mdrxy
Copy link

mdrxy commented Jul 22, 2024

@thoroc

Doesn't appear it is necessary anymore:

> brew tap "homebrew/cask"
"Error: Tapping homebrew/cask is no longer typically necessary."
"Add --force if you are sure you need it for contributing to Homebrew."

@odebroqueville
Copy link

Thank you for these explanations. They've helped me a lot. Just FYI:

Tapping homebrew/cask-fonts
Error: homebrew/cask-fonts was deprecated. This tap is now empty and all its contents were either deleted or migrated.

@vraravam
Copy link

vraravam commented Dec 1, 2024

@NH3R717 defaults might help. You could try to dump settings with defaults read and then apply them when restoring with defaults write. This is essentially what Mathias Bynens' .macos does. The concern that's stopped me from doing this is new settings / state stored in settings messing up a new machine but it should at least be possible.

What you said about the "new settings" (potentially from new versions of the apps/OS) is perfectly true.
I use a similar script to setup the "reference/base". And then apply the exported preferences from my old machine on top. This essentially (hopefully) ensures that the latest settings of each app are captured into the exported file from the old machine, and then can be reimported into the new machine. My script for both import and export is here - HTH

@anunayasri
Copy link

Awesome! Thanks for the writing this 👍

@BCtopics
Copy link

This helped a lot. Thank you for providing this openly to the public!

@ChristopherA
Copy link
Author

TODO: remove reference to tap "homebrew/cask, etc. as they are now automatically installed. Investigate other recommended taps to see if out-of-date.

@ChristopherA
Copy link
Author

TODO: investigate https://github.com/mas-cli/homebrew-tap reportedly bottles mas for older macOS now that new brew installs have mas pre-installed.

@arturmartins
Copy link

arturmartins commented Aug 19, 2025

Created this script 6 years ago and it's still quite useful today: https://gist.github.com/arturmartins/f779720379e6bd97cac4bbe1dc202c8b#file-mac-upgrade-sh

For .dotfiles, I recommend using chezmoi :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment