If you just opened your Mac terminal, tried to run a command, and were met with zsh: command not found: brew, don't worry. This is one of the most common errors for developers setting up a new Mac, and it's very easy to fix.

This guide will show you exactly what this error means and how to fix it step-by-step, whether you're on a new Apple Silicon Mac or an older Intel-based one.

Quick Fix: The 2 Most Common Solutions

  1. Homebrew isn't installed: You need to install it. Jump to Step 2.
  2. Homebrew is installed, but your shell can't find it: This is the most likely problem. Your system's PATH is missing the Homebrew directory.
  • For Apple Silicon (M1/M2/M3): Run echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
  • For Intel Macs: Run echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc

Why This Error Happens (The 2 Main Reasons)

Your terminal runs a shell program called Zsh (the Z shell). When you type a command like brew and press Enter, Zsh searches a specific list of folders on your computer to find that command's executable file. This list of folders is defined by an environment variable called PATH.

The error command not found means one of two things:

  1. Homebrew is not installed: The brew executable file doesn't exist anywhere on your system.
  2. Homebrew is in the wrong PATH: The brew executable file is on your system, but the folder it lives in is not included in your Zsh shell's PATH variable.

How to Fix "command not found: brew" (Step-by-Step)

We'll follow a simple diagnostic process.

Step 1: Check if Homebrew is Already Installed

First, let's see if the file actually exists. Open your terminal and run this command:

which brew
  • If your terminal responds with a file path like /opt/homebrew/bin/brew or /usr/local/bin/brew, it means Homebrew is installed. You can skip to Step 3, which is the correct fix for you.
  • If the terminal responds with brew not found or nothing at all, it means Homebrew is not installed. Proceed to Step 2.

Step 2: Install Homebrew (If It's Missing)

If the check in Step 1 failed, you need to install Homebrew.

  1. Open your terminal.
  2. Paste the following command, which is the official installation script from the Homebrew website:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Press Enter. The script will ask for your administrator password (the one you use to log in to your Mac). Type it and press Enter. You won't see the password as you type; this is normal.
  2. The script will run for a few minutes.

Expert Tip: After the installation finishes, read the terminal output. The Homebrew installer will often print a Next steps section. It usually tells you the exact commands you need to run to add Homebrew to your PATH. You can often just copy and paste those commands to finish the setup.

Step 3: Add Homebrew to Your Zsh Path (The Most Common Fix)

This is the most critical step and where the Apple Silicon vs. Intel difference matters. Homebrew installs to a different location depending on your Mac's processor.

  • Apple Silicon Macs (M1, M2, M3, etc.) install Homebrew to /opt/homebrew/bin.
  • Intel-Based Macs install Homebrew to /usr/local/bin.

You need to tell your Zsh shell (by editing the .zshrc file) where to look.

For Apple Silicon Macs (M1, M2, M3, etc.)

If you have a newer Mac with an M-series chip, follow these steps.

  1. Open your Zsh configuration file in a text editor. We'll use the simple nano editor:
nano ~/.zshrc
  1. This will open a text editor inside your terminal. Use the arrow keys to go to the very bottom of the file.
  2. Add the following line, which tells Zsh to add the Apple Silicon Homebrew folder to your PATH:
export PATH="/opt/homebrew/bin:$PATH"
  1. To save and exit: press Control + O (to Write Out), then Enter to confirm the file name, and finally Control + X to exit nano.

For Intel-Based Macs

If you have an older Mac with an Intel processor, follow these steps.

  1. Open your Zsh configuration file in nano:
nano ~/.zshrc
  1. Use the arrow keys to go to the very bottom of the file.
  2. Add the following line, which points to the Intel Homebrew folder:
export PATH="/usr/local/bin:$PATH"
  1. Save and exit: press Control + O, then Enter, then Control + X.

Step 4: Reload Your Terminal and Verify the Installation

The changes you just made to the .zshrc file won't take effect until you reload the file or open a new terminal window.

To reload it immediately, run this command:

source ~/.zshrc

This command forces Zsh to read your updated configuration file.

Now, test if it worked. Run the brew --version command:

brew --version

If the terminal successfully prints a version number (e.g., Homebrew 4.3.1), the error is gone! You have successfully fixed the problem.

Still Not Working? Try These Troubleshooting Commands

If you still see the error, here are two more expert-level checks.

Run brew doctor to Find Issues

Homebrew has a built-in self-diagnostic tool. Run it:

brew doctor

It will scan your system for common problems (like incorrect permissions or broken links) and tell you exactly how to fix them.

Check Which Shell Config File is Used (.zshrc vs .zprofile)

On some systems, Zsh is configured to read from .zprofile for login shells instead of .zshrc for every new shell. If the fix above didn't stick, try adding the same export PATH command to your .zprofile file as well.

  1. Open .zprofile:
nano ~/.zprofile
  1. Add the correct PATH line for your Mac (from Step 3) at the bottom.
  2. Save and exit (Control + O, Enter, Control + X).
  3. Reload the file:
source ~/.zprofile
  1. Try brew --version again.

What is Homebrew and the Zsh PATH? (A Quick Explanation)

For those new to this, here's a simple breakdown.

  • Homebrew: This is a package manager for macOS. It's a tool that makes it incredibly easy to install, uninstall, and manage software (especially developer tools like Python, Node.js, or Git) using the command line.
  • Zsh (Z Shell): This is the command-line program (shell) that your Mac's Terminal app uses by default. It's the environment you type commands into. It's one of several operating systems shells available.
  • The PATH: This is a simple list of folder locations. When you type a command, Zsh looks through every folder in this list until it finds a matching program to run. The error command not found simply means the folder where brew lives was not on that list. Editing your .zshrc file manually adds it.

Getting your environment set up is a key first step for anyone who wants to start coding or get deeper into programming on a Mac.