Sharing a Brewfile is the fastest way to get your team on the same page for development environments.
Here’s a Brewfile in action:
# Brewfile
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-versions"
# Core tools
brew "git"
brew "node"
brew "python@3.9"
brew "wget"
# Development tools
brew "docker"
brew "postgresql"
brew "redis"
brew "vim"
brew "neovim"
brew "emacs"
# GUI applications
cask "visual-studio-code"
cask "google-chrome"
cask "firefox"
cask "postman"
cask "slack"
cask "iterm2"
# Fonts
cask "font-fira-code"
To use this, everyone on your team would:
- Install Homebrew: If they don’t have it, they’d run
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"on macOS orbrew install --cask brew-installon Linux. - Save the
Brewfile: Create a file namedBrewfilein a shared repository (like Git) and paste the content above. - Run
brew bundle: Navigate to the directory containing theBrewfilein their terminal and executebrew bundle.
This single command will:
- Tap necessary repositories: It adds
homebrew/bundle,homebrew/cask, andhomebrew/cask-versionsif they aren’t already added. - Install command-line tools: It installs
git,node,python@3.9,wget,docker,postgresql,redis,vim,neovim, andemacsusingbrew install. If any are already installed, it will ensure they are up-to-date or skip them. - Install GUI applications: It installs
visual-studio-code,google-chrome,firefox,postman,slack, anditerm2usingbrew install --cask. - Install fonts: It installs
font-fira-codeusingbrew install --cask.
The beauty of brew bundle is that it’s idempotent. Running it multiple times will only install what’s missing or update outdated versions. This ensures that every developer, regardless of their current setup, can achieve the exact same development environment with a single command. It eliminates the "it works on my machine" problem by standardizing the tooling.
You can also specify versions if needed. For example, brew "node@18" would install Node.js version 18. For casks, you can use cask "firefox", version: "115.0.2". This level of control is crucial for projects with specific dependency requirements.
When you add a new tool or update a version, just update the shared Brewfile and have your team run brew bundle again. It’s a lightweight, version-controlled way to manage your entire development stack.
The Brewfile isn’t just for installing; it can also be used to remove packages. By adding a line like brew "package_name", uninstalled: true or cask "cask_name", uninstalled: true, brew bundle will remove that specific item if it’s present on the system. This is incredibly useful for cleaning up old or conflicting dependencies.
The next step is often integrating this Brewfile into your onboarding process for new team members.