The Mac Desk Notes on macOS, the small stuff included
Guides

Homebrew on Apple silicon, without the usual PATH mess

The installer gets the files right and leaves your shell half-configured. Five lines fix it for good.

· The Mac Desk · 1 min read

On an Apple silicon Mac, Homebrew lives in /opt/homebrew. That path is not in your PATH by default, which is why brew works in the terminal where you ran the installer and nowhere else, including in scripts, editors and anything launched from the Dock.

Install the command line tools first

xcode-select --install

A dialog appears and downloads a few hundred megabytes. It is a real dependency: Homebrew needs the compiler and headers, and without them many formulas fail in ways that look like broken packages.

Run the installer

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

Read the output before you continue: at the end it prints two commands it wants you to run, and those are the ones that matter.

If the script asks for sudo, that is for creating directories, not for the install itself. Never run brew with sudo. Packages installed as root end up owned by root and break the next upgrade.

Fix PATH once

Add this to ~/.zprofile, which zsh reads for login shells:

eval "$(/opt/homebrew/bin/brew shellenv)"

Then either open a new terminal or run the same line in the current one. Verify with:

brew --prefix      # /opt/homebrew
which brew         # /opt/homebrew/bin/brew
brew doctor

brew doctor prints warnings, not errors. A warning about unbrewed files in /usr/local is common on a Mac that once had an Intel Homebrew install and is usually harmless.

Make GUI apps see the same PATH

Terminal sessions are fixed. Apps launched from the Dock inherit a different environment, and that is why a build script in an editor cannot find brew. The supported fix is:

sudo launchctl config user path /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

This applies at the next reboot and affects every GUI application. It is a system-wide change, so set it deliberately and keep the list complete: setting a short PATH here can hide standard binaries from apps that expect them.

Keep it healthy

brew update && brew upgrade
brew cleanup --prune=all
brew list --versions | wc -l

brew cleanup removes old versions of installed formulas and is safe to run regularly. If a formula breaks after an upgrade, brew reinstall <name> is faster than debugging, and brew doctor will tell you when the prefix itself is in a bad state.

Keep reading