Homebrew is the de facto package manager for macOS, enabling developers and power users to install command-line utilities, programming runtimes, and desktop applications seamlessly. However, after installing Homebrew or migrating to a new Mac, entering brew commands in Terminal frequently produces the frustrating error: “zsh: command not found: brew”. Because macOS uses Z shell (zsh) as its default shell environment since macOS Catalina, this error indicates that the Homebrew executable binary directory is missing from your shell’s $PATH environment variable. The problem is particularly widespread on modern Apple Silicon Macs (M1, M2, M3, and M4 series) because Homebrew installs into a different file system path than on legacy Intel machines. This guide walks you through diagnosing your Mac architecture, adding Homebrew to your shell environment, and verifying the installation.
Understanding Homebrew Installation Paths Across Mac Architectures
To resolve command lookup failures in zsh, you must understand where Homebrew resides on your specific hardware. The table below details the architectural differences and required shell paths.
| Processor Architecture | Hardware Models | Default Homebrew Prefix | Target Executable Location |
|---|---|---|---|
| Apple Silicon (ARM64) | Apple M1, M2, M3, M4 (MacBook Air/Pro, Mac mini, Mac Studio, iMac) | /opt/homebrew |
/opt/homebrew/bin/brew |
| Intel (x86_64) | Legacy Intel Core i5/i7/i9 / Xeon (2020 and earlier Mac models) | /usr/local |
/usr/local/bin/brew |
| Rosetta 2 Emulation | Apple Silicon running Terminal under Rosetta emulation | /usr/local |
/usr/local/bin/brew |
Step 1: Check Your Mac Processor Architecture
Before adding configuration entries to your shell configuration profile, verify whether your Mac runs an Apple Silicon processor or an Intel chip:
- Open the Terminal application from Finder > Applications > Utilities.
- Run the following architecture lookup command:
uname -m - If the output returns
arm64, your Mac has an Apple Silicon processor, and Homebrew is located in/opt/homebrew. - If the output returns
x86_64, your Mac runs on Intel hardware, and Homebrew is located in/usr/local.
Step 2: Add Homebrew to Your Zsh Environment on Apple Silicon (M1/M2/M3/M4)
On Apple Silicon hardware, the Homebrew installation script installs files into /opt/homebrew to avoid colliding with system binaries in /usr/local. However, the script requires you to explicitly evaluate the shell environment in your user profile.
- In Terminal, execute the following commands to append Homebrew’s initialization code directly to your
~/.zprofilefile:echo >> ~/.zprofile echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile - Apply the updated profile configuration to your current active shell session:
eval "$(/opt/homebrew/bin/brew shellenv)" - Alternatively, reload your entire shell environment by running:
source ~/.zprofile
Step 3: Add Homebrew to Your Zsh Environment on Intel Macs
If you are operating an Intel-based Mac where Homebrew was installed into /usr/local, ensure the standard binary path is included within your profile configuration:
- In Terminal, check whether
/usr/local/binis present in your active path:echo $PATH - If
/usr/local/binis missing, append it to your~/.zshrcfile:echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc - Reload the configuration into your terminal session:
source ~/.zshrc
Step 4: Create a Universal Multi-Architecture Shell Configuration
If you share your dotfiles or sync your .zshrc file across multiple Mac machines (such as an Apple Silicon MacBook and an Intel Mac mini), hardcoding a single path can trigger errors on the other device. Use this dynamic conditional block in your ~/.zshrc:
- Open your
~/.zshrcin the Nano text editor:nano ~/.zshrc - Scroll to the bottom of the file and paste the following conditional logic:
# Universal Homebrew PATH detection if [[ -f /opt/homebrew/bin/brew ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" elif [[ -f /usr/local/bin/brew ]]; then eval "$(/usr/local/bin/brew shellenv)" fi - Save the file by pressing Ctrl + O, confirm with Enter, and exit by pressing Ctrl + X.
- Reload your shell profile:
source ~/.zshrc
Step 5: Verify Homebrew Installation and Run Diagnostics
Once your environment path is configured, confirm that Zsh correctly locates the binary and that your Homebrew installation is healthy:
- Verify the executable path:
which brewThe command should return
/opt/homebrew/bin/brewon Apple Silicon or/usr/local/bin/brewon Intel. - Check the installed version:
brew --version - Execute Homebrew’s built-in self-diagnostic utility to check for permission conflicts or missing Xcode Command Line Tools:
brew doctorIf the doctor report states “Your system is ready to brew”, your installation is completely configured and ready for package management.