By Tim Miller

If you are using a Mac and you get the brew command not found error message when trying to install Homebrew, then this article is for you. In this blog post, we will show how to fix that pesky brew command not found issue once and for all.

When you run Homebrew, you get this error message:

$ brew
-bash: brew: command not found

This error means Homebrew is misconfigured for some reason. Follow the solutions below to fix this issue.

Method 1: Provide the Path to Homebrew

By default, Homebrew should be installed in /usr/local/bin. It’s possible the path to Homebrew is missing and you can just specify it.

Type this command to see what Homebrew formulae you have installed:

$ /usr/local/bin/brew
Example usage:
  brew search TEXT|/REGEX/
  brew info [FORMULA|CASK...]
  brew install FORMULA|CASK...
  brew update
  brew upgrade [FORMULA|CASK...]
  brew uninstall FORMULA|CASK...
  brew list [FORMULA|CASK...]

  brew config
  brew doctor
  brew install – verbose – debug FORMULA|CASK

  brew create URL [--no-fetch]
  brew edit [FORMULA|CASK...]

Further help:
  brew commands
  brew help [COMMAND]
  man brew

If you don’t get the output above, you may get this error message:

$ /usr/local/bin/brew list
-bash: /usr/local/bin/brew: No such file or directory

If you get the error above, it means Homebrew isn’t installed on your computer. Follow our step-by-step guide on installing Homebrew on a Mac.

If the command above succeeds, it means Homebrew is installed but it’s not in your path. You can continue with the next method to fix this issue.

Method 2: Add Homebrew to your PATH (Temporary)

For this step, you need to add Homebrew to your path (which is a list of directory paths that are checked when looking for an executable program).

To make this change, run the command below:

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

After running this command, you should be able to run Homebrew now. You may want to follow the next method so you don’t have to keep running the command above before you run Homebrew.

pip is not recognized... FIXED! How...
pip is not recognized... FIXED! How To Properly Install Python Libraries

Method 3: Add Homebrew to your PATH (Permanent)

This is a permanent solution to fixing Homebrew when the path to Homebrew is missing. What you have to do is add Homebrew to your .bash_profile file.

To make this change, follow the steps below:

  • Open up the Terminal on a Mac.
  • Modify your PATH so it shows this line:
export PATH=/usr/local/bin:$PATH
  • Type this command to open your BASH profile:
sudo nano ~/.bash_profile
  • You will be prompted to enter your administrator password. Add the export line above to the .bash_profile file. If the file is not empty, add the export line to the end of the file.
  • Press Control + O (that is the letter O, not zero) to save the file.
  • Press Control + X to exit the nano editor.

That’s it! Just restart your terminal session and try running brew again as you did before getting this error message.

Method 4: Reinstall Homebrew

If the methods above don’t work for you, it’s time to reinstall Homebrew on your computer. Follow our guide on installing Homebrew on your Mac.

Leave a Comment