← Back to DevBytes

Homebrew Package Management

What is Homebrew?

Homebrew is the most popular open-source package manager for macOS and Linux. It allows developers to install, update, and manage command-line tools, libraries, and applications from a central repository of "formulae" (command-line software) and "casks" (graphical applications). Written in Ruby and deeply integrated with Git, Homebrew simplifies the process of keeping development environments consistent and up to date without needing to manually download, compile, or configure each tool.

Why Homebrew Matters for Developers

🚀 Deploy your AI agent in 10 minutes

Managed Hermes hosting. Zero DevOps. 100M tokens/mo included.

Try it free →

Homebrew solves several critical pain points for developers:

Installing Homebrew

To install Homebrew on macOS (requires Command Line Tools for Xcode) or Linux, run the following command in your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

The installer will guide you through prerequisites, ask for confirmation, and add the necessary paths to your shell profile. After installation, verify everything is working with:

brew doctor

If you see Your system is ready to brew., you’re all set. On Linux, you may need to install build tools like build-essential first.

Core Homebrew Commands

Installing Packages (Formulae)

To install a command-line tool or library (called a formula), use brew install. For example, to install Node.js:

brew install node

Homebrew fetches the latest stable version, resolves dependencies, and installs everything automatically. You can install multiple packages at once:

brew install git python@3.12 wget

Updating and Upgrading

Keep Homebrew itself and its package index fresh:

brew update

To upgrade all installed packages to their latest versions:

brew upgrade

To upgrade a specific package while leaving others unchanged:

brew upgrade node

Listing and Searching

See what packages you have installed:

brew list

Search for available packages by name or keyword:

brew search postgresql

Get detailed information about a formula (version, dependencies, install size):

brew info redis

Removing Packages

Uninstall a package and all its files:

brew uninstall node

To also remove unused dependencies after uninstalling, use the --ignore-dependencies flag if you want to force removal, or run the cleanup command afterwards (see below).

Managing Dependencies

View a formula’s dependencies before installing:

brew deps --tree imagemagick

Check which installed packages depend on a given formula:

brew uses --installed openssl@3

Working with Casks (GUI Apps)

Casks are Homebrew’s way of managing graphical desktop applications (like Firefox, VS Code, Docker Desktop). Install a cask with:

brew install --cask firefox

Search for casks specifically:

brew search --cask iterm2

List only installed casks:

brew list --cask

Cleaning Up

Over time, outdated versions and unused dependencies accumulate. Remove them and reclaim disk space:

brew cleanup

To simulate what would be removed without actually deleting anything:

brew cleanup --dry-run

Checking System Health

Regularly run brew doctor to diagnose problems like broken symlinks, missing dependencies, or permission issues:

brew doctor

Address any warnings to keep your environment reliable.

Best Practices

Using a Brewfile for Reproducible Environments

A Brewfile is a declarative list of packages, casks, and taps that can be used to recreate an environment. Generate one from your current setup:

brew bundle dump --file=~/Brewfile

The resulting file looks like this:

# Brewfile example
tap "homebrew/cask"
tap "homebrew/core"
brew "node"
brew "python@3.12"
brew "git"
cask "visual-studio-code"
cask "docker"

To install everything from a Brewfile on a new machine (or for a team member):

brew bundle install --file=~/Brewfile

This is perfect for onboarding, CI runners, and ensuring parity between development environments.

Advanced Tips

Pinning Versions

If your project relies on an older version of a tool (for example, Node.js 18 while the latest is 22), you can pin it to prevent brew upgrade from updating it:

brew pin node@18

To allow upgrades again:

brew unpin node@18

Pinning is useful but should be used sparingly – outdated pinned packages can miss security patches. Document pinned versions clearly in your project README.

Adding Custom Taps

Taps extend Homebrew with additional repositories. For example, to install a formula from a personal GitHub tap:

brew tap username/repo
brew install repo/some-formula

You can browse installed taps:

brew tap

Remove a tap you no longer need:

brew untap username/repo

Linking and Unlinking

Sometimes multiple versions of a package coexist. Homebrew uses symlinks to make a default version available in $PATH. To switch which version is active:

brew unlink python@3.12
brew link --force python@3.11

This is common when working with language versions like Python, Ruby, or PHP.

Using Homebrew Services

For packages that run background services (databases, web servers), Homebrew integrates with launchctl on macOS. Start a service:

brew services start postgresql@14

Stop it:

brew services stop postgresql@14

List all running services managed by Homebrew:

brew services list

This avoids manually writing plist files and keeps services bound to your user account.

Auditing and Formula Development

If you contribute to Homebrew or maintain private taps, you can validate your formula locally:

brew audit --strict my-formula

To test a formula from a local file before submitting it upstream:

brew install --build-from-source ./my-formula.rb

Conclusion

Homebrew is more than just a package installer – it’s a foundational layer for modern developer workflows. By centralizing tool management, enforcing clean separation from the system, and enabling reproducible setups via Brewfiles, it eliminates entire categories of environment-related bugs. Mastering its core commands and best practices will save you hours of manual configuration and make your development experience smoother, whether you’re working solo on a side project or scaling up a team. Start with a simple brew install, adopt incremental practices like brew bundle, and soon your terminal will feel like a well-organized workshop.

🚀 Need a reliable AI agent for your project?

Deploy Hermes Agent in 10 minutes. Managed hosting, zero DevOps.

Get Started — $23.99/mo
← Back to all articles