If you see zsh: command not found: brew, Homebrew is either installed but missing from your PATH or not installed at all. The fastest fix is to check your Mac’s processor, run Homebrew from its full path, and add the correct shellenv command to your shell profile. In this article, we will explain the possible causes of this error in detail and show you how to fix them.

zsh: command not found: brew

Quick fix: get brew working again

  1. Check your Mac’s architecture:

uname -m

  1. If the result is arm64, follow the Apple silicon steps below. If it is x86_64, use the Intel steps.
  2. After adding Homebrew to your profile, open a new Terminal window and run:

brew --version

If Terminal returns a Homebrew version number, the command is working again.

Please note: Running eval by itself fixes only the current Terminal session. Adding the same command to ~/.zprofile makes the fix persist when you open a new window.

Why does the brew command not found error appear?

Terminal searches a list of folders stored in the PATH environment variable whenever you enter a command. If the folder that contains Homebrew is not in that list, zsh cannot find brew and returns the error.

This error has two causes, and mixing them up is why so many fixes online don't work:

  • Homebrew is installed, but its location is missing from PATH. This is especially common on Apple silicon Macs because Homebrew installs in /opt/homebrew, which is not part of the standard system PATH.
  • Homebrew is not installed or its files are incomplete. This can happen after an interrupted installation or if Homebrew was removed.

The error can also appear if you’ve migrated from an Intel Mac to an Apple silicon Mac. An Intel Homebrew installation may remain in /usr/local, while native Apple silicon packages belong in /opt/homebrew.

How to solve “zsh: command not found: brew”

1. Check your Mac’s processor

Run:

uname -m

  • arm64 means you are using Apple silicon, such as an M1, M2, M3, M4, or newer M-series chip.
  • x86_64 means you are using an Intel Mac or an Apple silicon Terminal session running through Rosetta 2.

If you use Rosetta or keep both Homebrew installations, run this to check the architecture of the current shell:

arch

Both /opt/homebrew and /usr/local may exist on a mixed setup. Native Apple silicon Terminal sessions should normally use /opt/homebrew; Intel or Rosetta sessions may use /usr/local.

2. Add Homebrew to PATH

On an Apple silicon Mac

First of all, check whether the Homebrew executable exists:

/opt/homebrew/bin/brew --version

If you see a version number, Homebrew is installed and PATH is the problem. Add it to the current session:

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

Then make the change permanent:

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

source ~/.zprofile

On an Intel Mac

Test the standard Intel location:

/usr/local/bin/brew --version

If that works, add Homebrew to the current session:

eval "$(/usr/local/bin/brew shellenv)"

Then save the setting:

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

source ~/.zprofile

Close Terminal completely, open a new window, and run:

brew --version

This new-window test matters. If brew works before you close Terminal but fails afterward, the command was applied only to the current session or added to the wrong profile file.

Not sure which shell profile to use?

Run:

echo $SHELL

  • ~/.zprofileis the recommended macOS file for Homebrew’s shellenv command when you use zsh. It loads when a login shell starts.
  • ~/.zshrc< loads for every interactive zsh session. Adding shellenv there can work, including with Oh My Zsh, but ~/.zprofile matches the current Homebrew installer’s macOS instructions.
  • ~/.bash_profile is the corresponding file for bash users on macOS.

If your shell is bash, replace ~/.zprofile in the relevant command with ~/.bash_profile. For example, on Apple silicon:

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

source ~/.bash_profile

3. Check if it worked

Open a new Terminal window and run these commands:

brew --version

brew doctor

brew list

  • brew --version checks that Terminal can find Homebrew.
  • brew doctor checks Homebrew for problems. Ideally, you’ll see “Your system is ready to brew.” If you see a warning, read it carefully — some warnings are harmless, while others may point to something that needs fixing.
  • brew list shows the Homebrew packages and apps you already have installed.

Clean Homebrew caches with CleanMyMac CLI

Now that Homebrew is working again, it is a good time to check what your developer tools have left behind. brew list shows everything you’ve installed using Homebrew, but it does not show all the caches and generated files taking up space across Homebrew and other development tools.

CleanMyMac CLI brings that cleanup into Terminal. It is currently in public beta and requires macOS 11 or later and Homebrew, which makes it a natural next step after fixing the brew command.

Install it with Homebrew:

brew install --cask cleanmymac-cli

Once it’s installed, you can check that the command works with:

cleanmymac --version

To look specifically for files left behind by developer tools, use:

cleanmymac clean dev

CleanMyMac CLI will show you what it finds and how much space those files take up. You can review the results and deselect anything you want to keep before starting the cleanup.

If you first want a larger view of what is using your storage, run:

cleanmymac analyze

This opens an interactive disk usage explorer. Browsing does not change your files, and any removal still requires your explicit selection and confirmation.

What if Homebrew stopped working after a macOS update?

A major macOS update may leave the Xcode Command Line Tools missing, outdated, or unselected. This is separate from a PATH problem, so first make sure the full Homebrew path works, then run:

brew doctor

If the result reports a Command Line Tools problem, reinstall them:

xcode-select --install

Complete the installation by following the prompts. If Terminal then asks you to accept the Xcode license, run:

sudo xcodebuild -license

Read the license and follow the prompts. Then open a new Terminal window and repeat brew doctor.

What does “sudo: brew: command not found” mean?

Do not run Homebrew with sudo. Homebrew is designed to run as your normal user and refuses to work as root. sudo also uses a restricted PATH, which may exclude /opt/homebrew/bin even when brew works normally.

Use:

brew install <package-name></package-name>

For an app distributed as a cask, use:

brew install --cask <app-name></app-name>

If a script contains sudo brew, correct the script instead of changing sudo’s PATH.

Reinstall Homebrew (only if its files are missing)

You shouldn’t reinstall Homebrew just because brew is absent from PATH. First of all, test the full executable path for your Mac. If /opt/homebrew/bin/brew and /usr/local/bin/brew don’t exists, install Homebrew with the current command from the official website:

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

Read the installer’s “Next steps” and run the shellenv commands it gives you. For removal and a clean reinstall, see how to install and uninstall Homebrew on Mac.

What else to know about Homebrew errors

How to install the brew command on Mac?

Run the official installation script from brew.sh, then follow its “Next steps” to add brew shellenv to the correct profile for your Mac and shell.

How to fix a command not found error on Mac?

First, check that the command-line tool is installed. If its executable exists, add the folder that contains it to PATH in the correct shell profile, reload that profile, and test the command in a new Terminal window.

Can I install brew without sudo?

Yes. Homebrew can ask for administrator access while its installer creates the required directories, but normal brew install commands should run without sudo.

How to reinstall brew on Mac?

A PATH error doesn't need a reinstall. If the Homebrew executable is really missing, follow the official uninstall process, then run the current installer from brew.sh. In our complete Homebrew installation and removal guide, you can read all the details.

How to solve zsh command not found brew?

Run Homebrew from /opt/homebrew/bin/brew on Apple silicon or /usr/local/bin/brew on Intel. If it works, add its shellenv command to ~/.zprofile, reload the file, and confirm the fix in a new Terminal window.

One last tip: How to maintain your Mac

It’s a good idea to run regular maintenance on your Mac to prevent problems with it. That means reindexing Spotlight, flushing DNS cache, repairing disk permissions, and speeding up mail. Doing all that manually is time-consuming and difficult, but CleanMyMac’s Performance feature can do it for you. It takes only a few clicks and may save you a lot of trouble in the long run. Get your free CleanMyMac trial.

How to maintain Mac regularly with CleanMyMac

The error message ‘brew command not found’ means there is a problem with the installation of Homebrew on your Mac. Follow the steps above to fix it and get Homebrew running again.