Using Homebrew Brewfile Groups to Install Only Needed Dependencies
Learn how to organize a Brewfile with groups, install specific sets of dependencies, and keep your development environment reproducible without pulling unnecessary packages.
30 Sept 2025, 11:10 UTC

Problem: Installing everything when you only need a subset
When a project’s Brewfile lists all tools—linters, databases, IDEs—running brew bundle install on a CI agent or a fresh laptop pulls every package, wasting time and bandwidth.
Thesis: Brewfile groups let you declare dependencies once and install only the groups you need
By assigning formulae, casks, or MAS apps to named groups in a Brewfile, you can run brew bundle install --group <name> to install that subset, while still keeping a single source of truth.
Worked example: defining groups and installing a specific set
- Create a Brewfile at the project root:
# Brewfile
tap 'homebrew/core'
tap 'homebrew/cask'
# Development group
group 'development' do
brew 'git'
brew 'node'
brew 'yarn'
cask 'visual-studio-code'
end
# Testing group
group 'testing' do
brew 'jq'
brew 'shellcheck'
mas 'TestFlight', id: 899247664
end
# Default group (no group) – always installed
brew 'mas'
cask '1password'
- Install only the development group on a CI machine:
brew bundle install --group developmentThis command resolves dependencies for the formulae and casks inside the development block, skips the testing block, and installs any items outside of a group (the default mas and 1Password).
- Verify what would happen without making changes:
brew bundle install --group development --dry-runThe output lists each install, upgrade, or skip action, letting you confirm that only the intended packages are targeted.
- Check that the installed set matches the Brewfile:
brew bundle check --group developmentIf everything is satisfied, the command returns The Brewfile's dependencies are satisfied. Otherwise it lists missing items.
- Update the Brewfile to reflect the current state (optional):
brew bundle dump --forceThis overwrites the Brewfile with the current installed formulae, casks, and MAS apps, preserving any group syntax you had before.
Trade‑off: groups do not lock exact versions
Just like a plain Brewfile, a group does not record the version number of each formula unless you pin it explicitly (e.g., brew 'node@18'). Running brew bundle install --group development on a different day may fetch a newer release, causing subtle differences between environments. For strict reproducibility, add explicit version specifiers or commit a lockfile generated by brew bundle dump after you have verified the versions you want.
Another consideration is that evaluating groups adds a small overhead to the dependency resolution step; however, the overhead is negligible compared to the time saved by skipping unrelated packages.
Actionable next steps
- Add a Brewfile with groups to the root of your repository and commit it.
- In your CI configuration, install only the groups needed for that job (e.g.,
brew bundle install --group testingfor test runners). - Periodically run
brew bundle checkfor each group to detect drift, and update the Brewfile withbrew bundle dump --forcewhen you intentionally change a dependency.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.