C.W.K.
Stream
Lesson 09 of 14 · published

Package Management with Brewfile

~12 min · brewfile, homebrew, consistency

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

One file, identical packages

brew bundle + a Brewfile is the macOS equivalent of requirements.txt — declarative package management. List your packages once; every machine that runs brew bundle ends up with the same set installed. Combined with a dotfiles repo, new-machine setup is two commands.

What goes in a Brewfile

  • brew "name" — CLI tools (git, ripgrep, jq, mtr).
  • cask "name" — GUI apps (Tailscale, iTerm2, VS Code).
  • tap "user/repo" — third-party formulas not in the main brew.
  • mas "App Name", id: 12345 — App Store apps via the mas CLI.

Code

Generate from current state·bash
# Snapshot what's installed now
brew bundle dump --file=~/dotfiles/Brewfile

# Inspect
cat ~/dotfiles/Brewfile
A real-ish Brewfile·ruby
# Brewfile
tap "homebrew/cask"

# Networking & ops
brew "git"
brew "gh"
brew "iperf3"
brew "mtr"
brew "nmap"
brew "rsync"
brew "wget"
brew "jq"
brew "ripgrep"
brew "fd"
brew "bat"
brew "eza"
brew "starship"
brew "wireguard-tools"

# Dev
brew "node"
brew "python@3.12"
brew "miniconda"

# GUI
cask "tailscale"
cask "iterm2"
cask "visual-studio-code"
cask "raycast"
Apply and check·bash
# Install everything
brew bundle --file=~/dotfiles/Brewfile

# What's missing?
brew bundle check --file=~/dotfiles/Brewfile

# What would be installed (dry run)
brew bundle list --file=~/dotfiles/Brewfile

# Fleet-wide update
for host in $(cat ~/.fleet/all.txt); do
    echo "=== $host ==="
    ssh "$host" 'cd ~/dotfiles && git pull && brew bundle && brew update && brew upgrade'
done

External links

Exercise

Run brew bundle dump --file=~/dotfiles/Brewfile. Skim the output — recognize every package? Commit it. On a second Mac, run brew bundle --file=~/dotfiles/Brewfile. After it finishes, both machines have identical Homebrew state. That's fleet-level package consistency.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.