Provision a machine reproducibly with Homebrew Brewfile
Declare Homebrew formulas, casks, and Mac App Store apps in a Brewfile, then install only what is missing on another machine.
09 Apr 2026, 08:00 UTC

Problem: manual package setup is fragile
When you provision a new Mac or rebuild a workstation, it is easy to forget a formula, cask, or Mac App Store app. The omission usually appears later as a missing command or a broken editor extension. The useful answer is to declare your Homebrew environment in a Brewfile and reproduce it with `brew bundle install`, which installs missing entries and leaves already-installed packages alone.
Terms used in this guide
Homebrew is the package manager for macOS and Linux. A formula defines command-line software; a cask defines a macOS GUI application distributed as a binary; a tap is an extra repository of formulas or casks; and mas is the command-line tool for Mac App Store apps.
Worked Brewfile example
Create a file named `Brewfile` in your project or dotfiles repository:
tap "homebrew/services"
brew "git"
brew "postgresql@15"
cask "visual-studio-code"
mas "Example App", id: 1234567890 # replace with a real App Store identifier
Run these commands in a terminal on macOS, where Homebrew is already installed:
# Read-only diagnostic: list missing entries without changing anything.
brew bundle check --file=./Brewfile
# Install only the entries that are not already present.
brew bundle install --file=./Brewfile
Required permissions: a normal user account is sufficient, though Homebrew may prompt for your macOS password when it needs access to protected directories. Meaningful placeholder: replace `1234567890` with the actual App Store identifier for the app you want.
What `brew bundle` does
Homebrew parses the Brewfile as a Ruby DSL, resolves dependencies for each formula or cask, skips entries that are already installed, installs the missing ones, and prints a summary of installed, skipped, and failed items. `brew bundle check` is the read-only counterpart: it reports whether every entry is satisfied and exits with a non-zero status when something is missing, which makes it useful in continuous integration before a mutating install.
| Command | Effect | Use when |
|---|---|---|
| `brew bundle check --file=./Brewfile` | Read-only; reports missing entries | Before installing, or in CI validation |
| `brew bundle install --file=./Brewfile` | Installs missing entries; skips present ones | Ready to provision the machine |
| `brew bundle dump --describe --force` | Writes a Brewfile from currently installed packages | Auditing an existing machine or scaffolding a new file |
Limits and common mistakes
- A Brewfile captures Homebrew-managed packages only. It does not record system settings, dotfiles, user data, service startup configuration, or binaries installed outside Homebrew.
- Package versions are not pinned unless you specify them, such as `brew "postgresql@15"`. On a later machine, an unpinned formula may resolve to a newer version.
- `cask` entries are macOS-only and do not apply to Linux.
- `mas` entries fail if you are not signed into the Mac App Store, or if the identifier is invalid or the app has been removed.
- `brew bundle install` can install multiple packages and casks without asking for confirmation per item. Review the Brewfile before executing.
- Omitting a required `tap` for a third-party formula causes installation to fail.
- Do not expect `brew bundle install` to upgrade already-installed packages to their latest versions; it installs what is missing and skips what is present.
Verify before and after
Check your Homebrew version and bundle support:
brew --version
brew bundle --help
Generate a candidate Brewfile in a scratch directory to inspect what Homebrew currently considers installed:
brew bundle dump --describe --force
Then validate your committed file without installing anything:
brew bundle check --file=./Brewfile
A successful check prints that dependencies are satisfied and exits with code 0. If it lists missing entries, review them before running `brew bundle install`.
State change and rollback
`brew bundle install` changes system state. Homebrew does not provide a single command that reliably uninstalls every entry from a Brewfile in one step. If an install produces unwanted packages, remove them individually with `brew uninstall` or `brew uninstall --cask`, or remove the cask or formula from the Brewfile and manage the remaining entries manually. Because there is no automated rollback, treat the Brewfile as reviewed configuration before running the install command.
For your installed Homebrew version, confirm current flags with `brew bundle --help`, because output and flags can change between major releases.