Homebrew Cheatsheet - macOS Package Manager Reference
A fresh Mac loses hours to $PATH and dependency mess unless you install through Homebrew. This reference covers installing/updating/removing formulas, Cask GUI apps, brew services for background daemons, mirror switches for mainland use and troubleshooting broken bottles. Unlike a package list, it tells you which flag installs from HEAD vs a bottle, and how to diagnose a brew doctor complaint. After reading you can bootstrap and repair a Mac toolchain mostly from the terminal.
Typical Use Case
For macOS and Linux engineers whose workstation toolchain is managed by Homebrew. The recurring questions are always the same: why is this not updating, why did update break something, why is my install twice the size it should be, and why is a bottle refusing to download. This sheet covers the formula/cask split, update versus upgrade, services, taps, mirror switches, Brewfile-based reproducibility, and brew doctor as the first stop when the environment misbehaves.
Basics 12
brew install wgetbrew uninstall wgetbrew updatebrew upgradebrew upgrade wgetbrew listbrew info wgetbrew search nginxbrew cleanupbrew outdatedbrew reinstall wgetbrew autoremoveCask GUI Apps 5
brew install --cask visual-studio-codebrew uninstall --cask visual-studio-codebrew list --caskbrew search --cask chromebrew upgrade --caskServices 5
brew services listbrew services start mysqlbrew services stop mysqlbrew services restart mysqlbrew services run mysqlTaps & Mirrors 5
brew tap homebrew/cask-fontsbrew untap homebrew/cask-fontsbrew tapexport HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"Troubleshooting 7
brew doctorbrew configbrew deps wgetbrew pin wgetbrew unpin wgetbrew leavesbrew uses --installed wgetBundle Management 4
brew bundle dumpbrew bundle installbrew bundle cleanupbrew bundle checkParameter matrix
| Parameter | Effect | Example |
|---|---|---|
brew update | Refresh Homebrew itself and the formula/cask index; no installed package is upgraded | brew update |
brew upgrade | Upgrade installed formulae; GUI apps need the separate --cask path | brew upgrade --cask |
brew cleanup | Drop old versions and download caches - the fastest way to reclaim disk | brew cleanup |
brew pin | Freeze a formula against upgrades, useful when a newer version breaks | brew pin wget |
brew bundle | Dump, install or verify the toolchain from a Brewfile for reproducible setups | brew bundle dump |
Common pitfalls
Symptombrew update ran but git and node versions did not move at all.
Causeupdate only refreshes Homebrew and its index; upgrading happens in upgrade.
FixCheck with brew outdated, then run brew upgrade; for GUI apps use brew upgrade --cask.
Symptombrew install hits a dependency conflict and only succeeds with --force-overwrite.
CauseLeftover old versions contradict the new dependency requirement - the upgrade chain was never completed.
FixRun brew update && brew upgrade, then brew cleanup to drop stale versions; fall back to brew reinstall for that package.
SymptomBottle downloads crawl or fail repeatedly, while building from source fails on missing deps.
CauseThe default distribution host is often unreachable on some networks.
FixExport HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles" and retry.
SymptomThe disk is nearly full after months of installs, with several old versions stacked up.
CauseHomebrew keeps old versions and download caches around after every upgrade.
FixRun brew cleanup periodically, then brew autoremove to drop dependencies nothing needs.
SymptomTwo Homebrew installs coexist (arm64 and x86_64), commands shadow each other and brew doctor complains.
CauseBoth /usr/local and /opt/homebrew exist on an Apple Silicon machine, or an Intel migration left one behind.
FixCheck with brew config, keep one prefix, and put it first in PATH.
Troubleshooting
1Start with the built-in health check
brew doctorIt points at concrete issues: duplicate installs, PATH ordering, missing Command Line Tools.
2Assess the blast radius before upgrading
brew outdated && brew info wgetoutdated lists what can move; info gives version, dependencies and caveats, where breaking changes are recorded.
3Confirm installation and reverse dependencies
brew list && brew deps wget && brew uses --installed wgetdeps answers "what does it need"; uses --installed answers "who needs it" - opposite directions.
4Freeze the toolchain and reproduce it elsewhere
brew bundle dump && brew bundle installdump writes a Brewfile, install rebuilds from it on a new machine; brew bundle check verifies completeness.
Command Examples
Check the name and dependencies before installing
brew search nginx
brew info wget
brew listThe caveats printed by brew info often spell out extra PATH or configuration steps, so read them before installing.
Update, assess, then upgrade
brew update
brew outdated
brew upgrade
brew upgrade wgetupdate refreshes Homebrew itself only; outdated lists what could move, and you upgrade after reviewing that list.
Formulae and casks are managed separately
brew install --cask visual-studio-code
brew list --cask
brew search --cask chrome
brew upgrade --cask
brew uninstall --cask visual-studio-codeGUI applications live in the cask system, so plain brew upgrade leaves them alone; the --cask flag is required.
Service control and dependency health checks
brew services list
brew services start mysql
brew services run mysql
brew services restart mysql
brew services stop mysql
brew doctor
brew configstart registers the service for boot, run only affects the current session; the plist files live in ~/Library/LaunchAgents/.
Common Pitfalls
- brew update upgrades nothing; upgrading is brew upgrade and brew upgrade --cask, two separate paths.
- Do not reach for --force-overwrite on a dependency conflict: read brew info first, because forcing installs leaves the environment unreproducible.
- brew cleanup really deletes old versions and download caches, and the only way back is to reinstall; check brew leaves before running it.
- Two Homebrew prefixes on one machine (arm64 and x86_64) shadow each other, so run brew doctor first whenever commands behave strangely.
- When bottle downloads crawl or fail, switch the HOMEBREW_API_DOMAIN and HOMEBREW_BOTTLE_DOMAIN mirrors instead of falling back to building from source.
Tips
- On slow networks, switch mirrors before install, or bottle downloads often time out.
- Services managed by brew services live in ~/Library/LaunchAgents/; check there if something breaks.
- brew cleanup deletes old versions and download caches; run it when disk is tight.
FAQ
brew update finished but git and node are still old. Why?
Because update only refreshes Homebrew itself and its package index; it never touches installed packages. To actually upgrade, run brew upgrade, or brew upgrade wget for a single one. Check brew outdated first to see the upgrade list and judge whether anything is breaking. Another common case is upgrading only formulae: GUI applications live in the cask system and only move under brew upgrade --cask, and brew list and brew list --cask report two separate inventories.
How do I stop guessing the exact package name at install time?
Three steps. Run brew search nginx to get the real name, then brew info wget to check version, dependencies and caveats before committing, and brew list to see whether it is already installed and at which version. The cask equivalents are brew search --cask chrome and brew list --cask. If an install fails, resist reaching for --force-overwrite: brew info shows why the dependency conflict actually exists.
The disk is full of old versions and caches. What do I run first?
Start with brew cleanup, which removes old versions and downloaded caches and frees space the fastest. Follow up with brew autoremove for dependencies nothing needs any more, and brew bundle cleanup for packages absent from your Brewfile. Before running anything, check brew leaves to confirm which packages were installed at top level and that you are not about to delete something you rely on. Stale cask versions in the Caskroom go away through the same cleanup.
A tool crashes as soon as it upgrades. How do I freeze the version?
Run brew pin wget: brew upgrade skips pinned packages. Release it later with brew unpin wget once upstream has fixed whatever broke. To find out which installed package depends on it, run brew uses --installed wget, and to inspect its own requirements use brew deps wget. For a general health check of the environment, rely on brew doctor and brew config.
How do I reproduce this toolchain on a fresh machine?
Four commands close the loop: brew bundle dump exports the current installation into a Brewfile, you commit that file, brew bundle install applies it on the new machine, and brew bundle check verifies the requirements are satisfied while brew bundle cleanup removes anything not listed. Casks are recorded in the same Brewfile, so bundle manages both halves.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us