How to Fix ‘zsh: command not found: brew’ on Mac

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:

  1. Open the Terminal application from Finder > Applications > Utilities.
  2. Run the following architecture lookup command:
    uname -m
  3. If the output returns arm64, your Mac has an Apple Silicon processor, and Homebrew is located in /opt/homebrew.
  4. 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.

  1. In Terminal, execute the following commands to append Homebrew’s initialization code directly to your ~/.zprofile file:
    echo >> ~/.zprofile
    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
  2. Apply the updated profile configuration to your current active shell session:
    eval "$(/opt/homebrew/bin/brew shellenv)"
  3. 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:

  1. In Terminal, check whether /usr/local/bin is present in your active path:
    echo $PATH
  2. If /usr/local/bin is missing, append it to your ~/.zshrc file:
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc
  3. 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:

  1. Open your ~/.zshrc in the Nano text editor:
    nano ~/.zshrc
  2. 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
  3. Save the file by pressing Ctrl + O, confirm with Enter, and exit by pressing Ctrl + X.
  4. 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:

  1. Verify the executable path:
    which brew

    The command should return /opt/homebrew/bin/brew on Apple Silicon or /usr/local/bin/brew on Intel.

  2. Check the installed version:
    brew --version
  3. Execute Homebrew’s built-in self-diagnostic utility to check for permission conflicts or missing Xcode Command Line Tools:
    brew doctor

    If the doctor report states “Your system is ready to brew”, your installation is completely configured and ready for package management.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.