Skip to main content
macOSbeginner

"zsh: command not found: brew" - How to Fix on macOS

Fix the "zsh: command not found: brew" error on macOS. Add Homebrew to your PATH on Apple Silicon and Intel Macs, pick the right shell profile, and verify the fix.

6 min readUpdated August 2026

Typing brew install and getting "zsh: command not found: brew"? Homebrew is almost certainly installed - your shell just does not know where to find it. Here is the fix.

The Error

$ brew install wget
zsh: command not found: brew

On a Mac still running bash, the same problem prints:

bash: brew: command not found

Quick Fix (Apple Silicon)

Run these three lines in Terminal:

echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Then:

brew --version

On an Intel Mac, substitute the path:

echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/bin/brew shellenv)"

Why This Happens

When you type brew, zsh walks each directory in your PATH environment variable looking for an executable of that name. If it finds none, it reports command not found. That message says nothing about whether Homebrew exists on disk - only that it is not somewhere the shell was told to look.

On Apple Silicon Macs, Homebrew installs to /opt/homebrew. That directory is not on the default macOS PATH. The installer knows this, and at the end of a successful install it prints a "Next steps" section containing exactly the two lines above - but it deliberately does not edit your shell profile for you. Anyone who closes the terminal without reading that output ends up here.

On Intel Macs, Homebrew installs to /usr/local, and /usr/local/bin has been on the default PATH forever. That is why this error is overwhelmingly an Apple Silicon experience.

The split exists so that an Intel Homebrew running under Rosetta and a native ARM Homebrew can sit on the same machine without overwriting each other.


Step 1: Is Homebrew Actually Installed?

Do not guess. Check both locations:

ls /opt/homebrew/bin/brew    # Apple Silicon
ls /usr/local/bin/brew       # Intel
  • One of them lists the file - Homebrew is installed. This is a PATH problem; continue to step 2.
  • Both say "No such file or directory" - Homebrew is not installed. Skip to step 4.

Step 2: Add Homebrew to Your PATH

The recommended approach is brew shellenv rather than a hardcoded export PATH= line. shellenv emits the full set of variables Homebrew expects - PATH, MANPATH, INFOPATH and several HOMEBREW_ values - and picks the right prefix automatically, so the same line works on either architecture.

Append it to your profile and apply it to the current session:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

The second line matters. A shell reads its profile only when it starts, so without it you would have to open a new window before anything changed.

Inspect the result if you want to see what it did:

/opt/homebrew/bin/brew shellenv

Advertisement

Step 3: Check You Edited the Right File

Two things commonly go wrong here.

Wrong shell. Confirm what you are running:

echo $SHELL

/bin/zsh means ~/.zprofile is correct. /bin/bash means you want ~/.bash_profile instead. macOS has defaulted to zsh since Catalina, but an account created on an older system and carried forward through migrations can still be on bash.

Wrong profile file. zsh reads different files depending on how it was started:

FileRead by
~/.zprofileLogin shells - what Terminal.app and iTerm2 open by default
~/.zshrcInteractive shells - including many editor and IDE terminals
~/.zshenvEvery zsh invocation, including scripts

Homebrew recommends ~/.zprofile, and for Terminal.app that is sufficient. If brew works in Terminal but a tool such as an IDE's integrated terminal still cannot find it, that tool is spawning a non-login shell - add the same line to ~/.zshrc as well. Putting it in ~/.zshenv is not recommended, because it then runs for every script invocation too.


Step 4: Install Homebrew If It Is Missing

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

You will be prompted for your password, because the installer needs sudo to create its directories. Read the "Next steps" output at the end - it prints the exact PATH commands for your machine. Running those is what prevents you landing back on this error.


Step 5: Rule Out Rosetta

If Homebrew is at /opt/homebrew but your shell keeps behaving as though it should be at /usr/local, your terminal may be running translated:

uname -m
  • arm64 - running natively, as expected on Apple Silicon
  • x86_64 on an M-series Mac - your terminal is running under Rosetta

To change it: quit the terminal app, find it in Applications, press Cmd+I, and untick "Open using Rosetta." Reopen it. Unless you are deliberately maintaining an Intel toolchain, native is what you want.


Verify the Fix

# Version
brew --version

# Which binary answered
which brew

# Broader health check
brew doctor

Expected output:

Homebrew 4.4.0
/opt/homebrew/bin/brew
Your system is ready to brew.

If which brew returns nothing while /opt/homebrew/bin/brew --version works, the PATH line has not been applied to this shell - open a new window.


Prevention

  • Read the installer's "Next steps" output. It is not decoration; it contains the commands that finish the install.
  • Prefer eval "$(brew shellenv)" over a hardcoded export PATH=/opt/homebrew/bin:$PATH. The shellenv form keeps working if you move between Intel and Apple Silicon machines or if Homebrew changes its prefix.
  • Add the line once, to ~/.zprofile, rather than pasting it repeatedly - duplicated entries make PATH harder to reason about later.
  • After any migration to a new Mac, re-run the shellenv step. Migration Assistant copies your profile but not the Homebrew installation itself, which produces this error on a machine where it previously worked.

Summary

  1. Check: ls /opt/homebrew/bin/brew (Apple Silicon) or ls /usr/local/bin/brew (Intel)
  2. Installed but not found: append eval "$(/opt/homebrew/bin/brew shellenv)" to ~/.zprofile, then run the same line
  3. Not installed: run the install script from brew.sh and follow its "Next steps"
  4. Still failing: check echo $SHELL and uname -m
  5. Verify: brew --version and brew doctor

Frequently Asked Questions

Find answers to common questions

Your shell searched every directory in PATH and found no executable called brew. On Apple Silicon Macs this usually means Homebrew is installed at /opt/homebrew but was never added to your PATH, because the installer prints those instructions rather than applying them for you. Less often, Homebrew is genuinely not installed.

Check directly. Run 'ls /opt/homebrew/bin/brew' on an Apple Silicon Mac or 'ls /usr/local/bin/brew' on an Intel Mac. If the file is listed, Homebrew is installed and this is purely a PATH problem. If both return "No such file or directory", you need to install it.

Homebrew moved to /opt/homebrew for Apple Silicon so that Intel and ARM installations can coexist on the same machine without colliding. The tradeoff is that /opt/homebrew is not on the default macOS PATH, while the Intel location /usr/local/bin always has been - which is why the error is far more common on M-series Macs.

Use ~/.zprofile, which is what Homebrew's own installer recommends. Terminal.app opens login shells, which read .zprofile. If a tool that spawns a non-login shell still cannot find brew, add the same line to ~/.zshrc as well.

It prints the environment variables Homebrew needs - PATH, MANPATH, INFOPATH and a few HOMEBREW_ variables - and wrapping it in eval applies them to your current shell. Using shellenv instead of hardcoding a PATH line means the correct prefix is used automatically whether you are on Intel or Apple Silicon.

A shell reads its profile only at startup. Either run 'eval "$(/opt/homebrew/bin/brew shellenv)"' to apply it to the window you are in, or close the terminal and open a new one. Also confirm you edited the profile for the shell you are actually running - check with 'echo $SHELL'.

Yes, with slightly different wording - bash prints "bash: brew: command not found". The cause is identical. Add the same eval line to ~/.bash_profile instead of ~/.zprofile. macOS has defaulted to zsh since Catalina, so most people see the zsh form.

Yes. If your terminal is running under Rosetta, 'uname -m' reports x86_64 and the shell looks for the Intel Homebrew in /usr/local, which may not exist. Check the Get Info panel of your terminal app and untick "Open using Rosetta" unless you specifically need it.

Run the official install script from brew.sh, then follow the "Next steps" instructions it prints at the end - those instructions are the PATH lines this article covers, and skipping them is the single most common reason people end up with this error.

Run 'brew --version' for a version number, 'which brew' to confirm the path, and 'brew doctor' for a broader health check. "Your system is ready to brew" means the installation is sound.