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. 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. 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. 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. 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. 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
200 characters left
Include your email address to get a message when this question is answered.
Submit
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

You Might Also Like

Zsh: Permission Denied Fix the Zsh: Permission Denied Error on Mac
Check Path in UnixCheck Path in Unix
Set Java Home Set JAVA_HOME for JDK & JRE: A Step-by-Step Guide
Sudo Command Not Found2 Ways to Fix the "Sudo Command Not Found" Error on Linux
Install Pip on Mac3 Easy Ways to Download & Install Pip on Your Mac
Run a Program from the Command Line on LinuxRun a Program from the Command Line on Linux
Use Telnet on Mac OS X Install and Use Telnet on macOS
Run Ruby CodeRun Ruby Code
Update Pip Upgrade Pip: Quick Guide for Beginners & Experts
Check Python Version on PC or Mac See the Python Version on Mac, Windows, and Linux
Open Applications With Root Privileges on a Mac Run Apps with Root Permissions on a Mac
Java Macos Uninstall Uninstall Java & JDK on Mac: Step-by-Step Tutorial
Check Java Version on a Mac Quickly and Easily Check Java Version on a Mac
The Recovery Server Could Not Be Contacted6 Ways to Fix “The recovery server could not be contacted” on a Mac
Advertisement

About This Article

Stan Kats
Reviewed by:
Professional Technologist
This article was reviewed by Stan Kats and by wikiHow staff writer, Megaera Lorenz, PhD. Stan Kats is a Professional Technologist and the COO and Chief Technologist for The STG IT Consulting Group in West Hollywood, California. Stan provides comprehensive technology solutions to businesses through managed IT services, and for individuals through his consumer service business, Stan's Tech Garage. Stan holds a BA in International Relations from The University of Southern California. He began his career working in the Fortune 500 IT world. Stan founded his companies to offer an enterprise-level of expertise for small businesses and individuals.
How helpful is this?
Co-authors: 3
Updated: August 20, 2025
Views: 492
Categories: Programming
Thanks to all authors for creating a page that has been read 492 times.

Is this article up to date?

Advertisement