Homebrew is the de-facto package manager for macOS. But if you’re using it there are some things you need to know…
By default Homebrew is collecting anonymous analytics data from you, and publishing stats on its website. If you don’t like the sound of that, export HOMEBREW_NO_ANALYTICS=1 in your shell environment (tip: put it in your zshrc file and use chezmoi to avoid ever losing it!).
The days of using Homebrew with sudo are long gone… or should be. Running it as a privileged user was never a good idea, but if you’ve been using this tool for a while you’ll know some advice made its way online to ‘just use sudo’ to solve X or Y problem, and if you were trying to save time that might be what you did. But it opens a pandora’s box, so much so that Homebrew itself will warn against doing this if it can detect it.
How do you know if your (home)brew’ing wrong? Use the
brew doctor
command! It’ll detect issues like a misconfigured shell/path. If things are good, it will say “Your system is ready to brew”.
Struggling with all of this brewing nomenclature?
📝 Formula: a package, which is essentially a ruby script used by Homebrew to install software.
📝📝 Formulae: this (plural) term is used when talking about multiple packages/formula’s.
📦 Cask: a formula/package, but specifically designed for installing GUI software like 1Password or Slack. Originally an extension to Homebrew but now built-in!
🚰 Tap: third-party repository. It’s pretty easily to make your own if you’re using Go, check out the GoReleaser project for this.
🍾 Bottle: pre-built binary (fast!). If one matching your OS/CPU/etc doesn’t exist, it’ll build from source (slow!).
🛢 Keg: path to where a formula/package is installed.
🏠 Cellar: the directory where all the Kegs are stored i.e. `/opt/homebrew/Cellar`
Keeping up-to-date is important, and `brew upgrade` is the command you’ll want to run to upgrade outdated formulae/packages and casks/GUI packages. But why don’t some get upgraded? Many Casks (GUI packages) self-update, so homebrew Casks are often configured to be excluded during `brew upgrade` to avoid issues/conflicts.
Last tip: Brewfile’s. For those in the Ruby world familiar with bundler, it’s like a Gemfile but for your Homebrew formulae (packages) and casks (GUI packages). A quick primer on the `brew bundle` commands:
📤 `brew bundle dump` creates a Brewfile from everything currently installed
🕵️ `brew bundle check` checks if things in your Brewfile are all installed correctly
📥 `brew bundle install` (or just `brew bundle`) installs and upgrade stuff in your Brewfile. It also creates a `Brewfile.lock.json` file which captures bottle URLs, paths, and sha256 sums, etc.
Like this post? Want more tips on developer tools and productivity? Follow me at x.com/@ryan0x44