C.W.K.
Stream
Lesson 05 of 05 · published

Homebrew Wisdom — Things Only Pain Teaches

~12 min · homebrew, wisdom, gotchas, production

Level 0Newbie
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

Homebrew is friendly until it isn't. The friendly part lasts about six months; then you hit one of these traps and a workshop's worth of wisdom drops on your head. Here's the wisdom without the workshop.

Never use sudo brew. It's the number one cause of broken Homebrew installs. The Cellar must be owned by your user. If you've already done it, repair with sudo chown -R $(whoami) /opt/homebrew.

Pin versions you depend on. If your codebase needs Python 3.12 specifically, install python@3.12 (versioned formula) instead of python (always latest). When 3.13 ships and changes a stdlib API, you won't lose a morning.

Use brew autoremove regularly. Every install pulls in dependencies. When you uninstall the parent, the deps stay — over time, they pile up. brew autoremove safely removes anything no longer needed.

Keep a Brewfile in your dotfiles. Even if you only own one Mac today, future-you will own another. A Brewfile collapses "reinstall my whole dev setup" from a half-day to a coffee break.

Watch caveats. Some packages need PATH additions, shell hooks, or post-install service registration. brew info prints them; reading them at install time saves a frustrated debugging session two weeks later.

Code

Repair an Apple Silicon Mac that has 'sudo brew' damage·bash
# Symptom: 'brew install' errors out with 'Permission denied'
# Cause: someone (you, in 2023) ran 'sudo brew install ...' once.
# Fix: take back ownership of the prefix you own.

sudo chown -R "$(whoami)":admin /opt/homebrew

# Then verify
brew doctor
Versioned formulae — pin what your code needs·bash
# Generic name = always latest
brew install python

# Versioned name = stable across upgrades
brew install python@3.12
brew install postgresql@16
brew install node@22

# When the unversioned formula updates, your code keeps working.
Weekly maintenance ritual·bash
# Run this weekly, e.g. via a launchd job or a Sunday-morning habit
brew update
brew upgrade
brew autoremove        # delete unused dependencies
brew cleanup --prune=all  # delete old archives, all old versions
brew doctor            # confirm everything is healthy

External links

Exercise

Run the weekly maintenance ritual (update + upgrade + autoremove + cleanup + doctor) right now. Note how long it takes and how many packages get cleaned up. Then commit your refreshed Brewfile to a dotfiles repo (private or public). Even a personal one-Mac dotfiles repo on GitHub becomes invaluable the day you wipe a disk.

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.