PDF download Download Article
Get Homebrew working on your zsh terminal in minutes
PDF download Download Article

Did you just install Homebrew, only to find that your Terminal won’t recognize brew commands? Homebrew is a versatile package manager for macOS or Linux. While installing it is pretty straightforward, there are a few key steps that are easy to overlook. Unfortunately, missing these steps will cause brew commands to fail, triggering a “zsh: command not found: brew” error. In this article, we’ll explain the usual reasons for this error and how to fix it.

How to Fix the Zsh: Command Not Found: Brew Error

This typically means that either Homebrew is not installed or that its path is not in your shell's configuration file. First, restart Terminal to refresh your session. If that doesn’t work, make sure Homebrew is actually installed . If it is, you need to add Homebrew's path to your .zprofile file.

Section 1 of 4:

What does “zsh: Command Not Found: Brew” mean?

PDF download Download Article
  1. If Terminal is unable to recognize brew commands, it most likely means that you haven’t completed the Homebrew installation. Either Homebrew is not installed at all, or the shell config file hasn’t been updated with the correct Homebrew path. You might also simply need to refresh your shell session if you just installed Homebrew.
  2. Advertisement
Section 2 of 4:

Restarting Terminal

PDF download Download Article
  1. 1
    Quit Terminal and restart it. In some cases, fixing this error is as simple as starting a new shell session. Typically, you need to restart the Terminal right after installing Homebrew in order for it to work correctly.
  2. 2
    Run the brew doctor command. Once Terminal restarts, run this command to check if Homebrew is working. If it is, you should see a message saying Your system is ready to brew .
    • If your version of Homebrew is outdated, this command might trigger an update. If so, it may take a few minutes for the process to complete.
    • If you see the zsh: command not found error after running brew doctor , that means Homebrew isn’t installed correctly or the $PATH hasn’t been set in the shell config file.
  3. Advertisement
Section 3 of 4:

Checking Your Homebrew Installation

PDF download Download Article
  1. Enter the brew --version command. If Homebrew is installed, this should trigger Terminal to display the current version (e.g., Homebrew 4.4.21 . [1]
    • You can also use the brew doctor command to check. This time, include the full path:
      • If you have an Apple Silicon chip (M1, M2, M3, or M4), use this command: /opt/homebrew/bin/brew doctor
      • For older Macs with Intel processors, use the command /usr/local/bin/brew doctor
      • In Linux, try /home/linuxbrew/.linuxbrew/bin/brew doctor .
      • If this command returns the message Your system is ready to brew , that means that Homebrew is installed, but the $PATH hasn’t been set correctly in the shell config file.
    • If Homebrew isn’t installed, you’ll need to install it before you can continue. Check out this article from the official Homebrew website for detailed installation instructions.
Section 4 of 4:

Setting the PATH

PDF download Download Article
  1. After you install Homebrew, you’ll need to update your shell’s config file before you can run any brew commands. To run this command correctly, you’ll need to figure out the default path to Homebrew on your system. [2]
    • If you have a Mac with an Apple Silicon chip (M1, M2, M3, or M4), the default install location is /opt/homebrew. [3]
    • For Intel Macs, the default path is /usr/local.
    • On Linux, it’s /home/linuxbrew/.linuxbrew.
  2. 2
    Update your shell’s config file with the correct Homebrew path. Typically, you can do this from within Terminal when you first install Homebrew. Right after installation, you’ll see a line in the Terminal window that says something like this:
    • Next steps: - Add Homebrew to your PATH in /Users/$USER/.zprofile:
      echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile
      eval $(/opt/homebrew/bin/brew shellenv)
      • Copy and paste the line echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile into the Terminal window and press Return .
      • The exact format of the line will depend on your system and Homebrew’s install location.
      • Then, copy and paste eval $(/opt/homebrew/bin/brew shellenv) into Terminal and press Return again.
      • Quit Terminal and reopen it. You should now be able to use Homebrew.
  3. 3
    Update the configuration file manually if needed. If you didn’t follow these steps when you initially installed Homebrew, you can still update the config file manually. Here’s how:
    • First, you may need to create the correct config file by entering the command touch ~/.zprofile in Terminal.
    • Enter the command open -e ~/.zprofile to open the file in TextEdit.
    • Add the following line to the file: eval "$(<Homebrew prefix path>/bin/brew shellenv)" .
    • Replace “<Homebrew prefix path>" with the appropriate location prefix for your system (e.g., “/opt/homebrew” on a Mac with Apple Silicon).
  4. Once you’ve updated the shell config file, you’ll need to restart your shell session. Either quit Terminal and restart, or use the command source ~/.zprofile to reset the shell environment.
    • Once Terminal restarts, you should be able to run brew commands!
  5. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Video

      Tips

      • In rare cases, you’ll still get the Command Not Found error even if Homebrew is installed and the $PATH is set correctly. In these cases, you might need to uninstall and reinstall Homebrew. You can find instructions for uninstalling Homebrew here.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Name
      Please provide your name and last initial
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Thanks to all authors for creating a page that has been read 60 times.

      Is this article up to date?

      Advertisement