macOS CMD_NOT_FOUNDMedium

Error 'brew command not found' on macOS: causes and solutions

Article explains why the system can't find the brew command and provides proven solutions: installing Homebrew, configuring the PATH variable, and reloading the shell.

Updated at February 16, 2026
5-15 minutes
Easy
FixPedia Team
Применимо к:Homebrew on macOS 10.14 Mojave and above

What the 'brew command not found' Error Means

The error brew: command not found (or zsh: command not found: brew in the zsh shell) appears when you try to run the brew command in the macOS terminal, but the system cannot find the executable file for that command. This means that the directory where brew is located is missing from the PATH environment variable. Homebrew is a package manager for macOS, and without it, you won't be able to install or update software via the terminal.

Typical full error text:

zsh: command not found: brew

or

bash: brew: command not found

Causes

  1. Homebrew is not installed. You are trying to use the brew command, but the Homebrew program itself is missing from the system.
  2. The path to Homebrew is not added to PATH. Homebrew is installed (e.g., in /opt/homebrew/bin for Macs with Apple Silicon or /usr/local/bin for Intel), but this directory is not included in the PATH variable, so the terminal doesn't know where to look for the executable.
  3. The shell configuration file is not loading. The terminal uses a shell (e.g., zsh), but configuration files (such as ~/.zshrc), where the PATH is defined, are not loaded when starting a new session.
  4. Homebrew installation is corrupted. The Homebrew files may have been damaged during installation or after a system update.

Method 1: Install Homebrew

If Homebrew is not installed, start by installing it. This is the simplest and most common solution.

  1. Open Terminal in macOS.
  2. Run the official installation command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Follow the on-screen instructions. The installer will ask for your administrator password and to press Enter to confirm.
  2. After installation completes, add Homebrew to your PATH if the installer did not do it automatically. For Apple Silicon Macs (M1/M2/M3), run:
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)"
  1. Close and reopen the terminal or run source ~/.zprofile.

Method 2: Add the Homebrew Path to the PATH Variable

If Homebrew is already installed but the brew command is not recognized, most likely the path to Homebrew is not in your PATH. This often happens after a macOS update or when using custom shell settings.

  1. Determine which shell you are using:
echo $SHELL

Typical output: /bin/zsh (default since macOS Catalina) or /bin/bash.

  1. Open the configuration file for your shell in a text editor (e.g., using nano or vim):
    • For zsh: nano ~/.zshrc
    • For bash: nano ~/.bash_profile or nano ~/.bashrc
  2. Add the following line to the end of the file with the path to Homebrew:
    • For Apple Silicon (Macs with M1 chip and newer):
      export PATH="/opt/homebrew/bin:$PATH"
      
    • For Intel:
      export PATH="/usr/local/bin:$PATH"
      
  3. Save the file (in nano: Ctrl + O, then Enter, then Ctrl + X).
  4. Apply the changes by running:
source ~/.zshrc   # for zsh

or

source ~/.bash_profile   # for bash

If you are unsure of the filename, you can simply restart the terminal.

  1. Verify that brew is now available:
which brew

The output should show the path, e.g., /opt/homebrew/bin/brew.

Method 3: Check and Reload the Shell

Sometimes changes to PATH do not apply because the terminal is using a different shell or configuration files are loaded incorrectly.

  1. Ensure you edited the correct configuration file. macOS may use several files:
    • For zsh: ~/.zshrc (for interactive shells) and ~/.zprofile (for login shells). If ~/.zshrc did not work, try adding the export PATH line to ~/.zprofile.
    • For bash: ~/.bash_profile (for login shells) or ~/.bashrc (for interactive non-login shells).
  2. If you do not know which shell is active, run:
ps -p $$ -o comm=

This will show the current shell.

  1. After editing the file, fully restart the terminal (close the window and open it again) or run:
exec $SHELL -l

This restarts the shell as a login shell, loading all configurations.

  1. Check your PATH:
echo $PATH

Ensure the Homebrew path (e.g., /opt/homebrew/bin) appears in the output.

Method 4: Reinstall Homebrew

If the previous methods did not help, the Homebrew installation may be corrupted. In this case, perform a full reinstall.

⚠️ Important: Reinstalling will remove all packages installed via Homebrew. Create a backup of your package list: brew list > brew_backup.txt.

  1. Uninstall Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
  1. Ensure all files are removed:
sudo rm -rf /opt/homebrew   # for Apple Silicon
sudo rm -rf /usr/local/Homebrew   # for Intel
  1. Install Homebrew again, as described in Method 1.

Prevention

To avoid the error recurring:

  • Always use the official Homebrew installation script. Do not download or move files manually.
  • After installation, check your PATH: run echo $PATH and ensure the Homebrew path (e.g., /opt/homebrew/bin) is present.
  • Update Homebrew regularly: brew update and brew upgrade.
  • If you change shells (e.g., from bash to zsh), ensure the configuration files for the new shell contain the PATH settings.
  • When updating macOS, check if the PATH settings were reset. Sometimes you need to re-add Homebrew to the configuration files.

F.A.Q.

Why does the 'brew command not found' error occur?
How to check if Homebrew is installed?
What to do if brew is installed but the command doesn't work?
How to add brew to PATH manually?

Hints

Install Homebrew
Add brew path to PATH
Reload the terminal
Verify the installation
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community