How to Fix “zsh: command not found: brew” on Mac

Development

If you’ve ever attempted to install or use a package using the Terminal in macOS only to be met with the error message:

zsh: command not found: brew

—don’t worry, you’re not alone. This error typically pops up when the Homebrew package manager is not installed or not configured properly. In this article, we’ll walk you through how to fix this issue so you can get back to installing software and managing packages on your Mac with ease.

What Is Homebrew?

Homebrew is a popular package manager for macOS that makes it incredibly easy to install and manage software directly from the command line. It’s especially popular among developers and tech-savvy users who prefer using Terminal for software installations.

However, if you’re seeing this error, it means your system can’t find the brew command, which indicates one of the following:

  • Homebrew is not installed.
  • Homebrew was installed, but it’s not in your shell’s PATH.
  • You’re using a shell (like zsh) that doesn’t know where to look for the brew command.

Step-by-Step Fix for “command not found: brew”

1. Check If Homebrew Is Installed

First, double-check that Homebrew is actually installed. Open Terminal and run:

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

This command downloads and runs the official Homebrew installation script. If Homebrew is already installed, it will let you know. Otherwise, it will install it for you.

2. Add Homebrew to Your PATH

Once Homebrew is installed, it’s important that your shell knows where to find it. You can check where Homebrew is installed by running:

echo $(brew --prefix)

It usually installs to one of these two locations:

  • /opt/homebrew on Apple Silicon Macs (M1/M2)
  • /usr/local on Intel Macs

If installing didn’t fix the issue and you still see the error, you’ll need to manually add the brew directory to your shell’s PATH.

For Apple Silicon Macs:

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

For Intel Macs:

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

This ensures that every time you open a Terminal session using the Zsh shell, Homebrew is available in your PATH.

3. Restart Your Terminal

After modifying your configuration files, always restart your Terminal for the changes to take effect. This reloads your shell and makes sure the path changes are in effect.

4. Verify Installation

Now, to make sure everything’s working properly, type:

brew help

If the command gives you a list of brew commands and usage instructions, congratulations — you’ve resolved the error!

Bonus Tip: Use a Zsh Configuration Manager

To make shell configuration easier in the future, consider using a tool like Oh My Zsh. It provides themes, plugins, and easier management of your .zshrc and .zprofile files. That way, adding commands like Homebrew setup becomes less intimidating.

What If It Still Doesn’t Work?

If you’ve followed the steps and are still getting the same error, consider the following troubleshooting tips:

  • Double-check that the correct Homebrew path is being used for your chip architecture (Intel vs Apple Silicon).
  • Look for typos or missing quotation marks when editing .zprofile or .zshrc.
  • Try running which brew to check if the system can detect its location.

As a last resort, you can completely uninstall and reinstall Homebrew by following the official guide on the Homebrew website.

Conclusion

Seeing “zsh: command not found: brew” can be frustrating, especially when you’re in the middle of installing a package or setting up a development environment. But the fix is usually straightforward: install Homebrew and make sure your Zsh shell knows where to find it.

Once properly set up, Homebrew becomes an indispensable tool for your macOS Terminal experience — one that simplifies installing everything from software libraries to popular developer tools.