How to Fix “zsh: command not found: brew” Error in Mac Homebrew

url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url url

If you see the error “zsh: command not found: brew” while using Homebrew, it likely means that the Terminal app can’t find the Homebrew executable. Don’t worry, as we’ll explore some potential solutions to fix this issue below.




1. Try reinstalling Homebrew.

macOS Terminal window for installing Homebrew

Reinstalling Homebrew can remove any corrupted or outdated files and install a fresh copy of Homebrew. To remove Homebrew, you can follow these steps:

  1. Open Terminal on your Mac and uninstall Homebrew by pasting the following command and pressing Come back key:
    brew uninstall  
  2. Type the following command and press Come back To install Homebrew again:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 

This will download and install the latest version of Homebrew. Once you restart the Terminal app, you should be able to use the brew command without any issues.


2. Add Brew to your PATH environment variable.

There is a high probability that Homebrew was unable to add to the PATH variable during installation, which means that your shell is unable to locate the Homebrew executable.

You can fix this issue by manually adding Homebrew to your PATH via Terminal. The command is slightly different depending on whether your Mac has an Intel processor or an Apple silicon chip. Just copy and paste the appropriate command for your Mac into the Terminal app.

If you have a Mac with Apple silicon, enter this command:

export PATH="/opt/homebrew/bin:$PATH" 

If your Mac has an Intel processor, enter this command instead:

export PATH="/usr/local/bin:$PATH" 

You can verify that Homebrew has been successfully added to the PATH variable using the following command:

echo $PATH 
macOS Terminal windows display all executable files available via the echo $PATH command.


This will display all the executable binary files that Terminal can find. If Homebrew is in the list, it means that Terminal was able to successfully locate the Homebrew executable file.

Command Prompt on macOS offers to download Xcode command line tools

Xcode Command Line Tools is a package developed and maintained by Apple that contains all the debugging tools, compilers, and tools included in the entire Xcode IDE. Many users have reported that Homebrew cannot work without Xcode Command Line Tools installed. You can install it by typing the following command in Terminal and pressing Come back:

xcode-select  

After that, you can verify the installation using the following command:

xcode-select -p 

If the installation is successful, you should get the following output after entering the command:


/Library/Developer/CommandLineTools 

Homebrew offers many useful applications and is a must-have utility for every power user of Mac. If you are facing the “zsh: command not found: brew” error, one of the troubleshooting steps we discussed above should solve the problem and allow you to enjoy the best package manager available for macOS.

Leave a Comment