Brew command not found for Apple’s macOS and Linux Operating system

Brew command not found for Apple's macOS and Linux Operating system

Brew command not found for Apple’s macOS and Linux Operating system

Homebrew is a free and open-source software package management system for Apple’s macOS and Linux Operating system, allowing users to install the software in the system quickly. The package is programmed upon Ruby and Github to fetch installs, update apps, and add repositories where developers can add applications to be managed through command-line interfaces. 

When users attempt to install Homebrew on their computer, they get a message that says “brew: command not found.” This article is going to show you a few possible fixes to the error.

What is Homebrew?

According to the user, Homebrew (Brew) is an open-source and free package manager that allows the user to install apps and software in macOS. The application is known for its user-friendly interface and effective software performance. Its famous description is “The missing package manager for macOS.”

It is pretty impressive to take advantage of the power of using the latest and updated version of software on your Mac on your device. Homebrew offers formulae packages to install from its core public repository to your device directly. In addition, there is the cask (brew-cask) which is an extension to enrich you with additional software packages and binary apps using the command line.

If you want to know some benefit examples of using Homebrew from what experts said, read the following:

  • It collects all your variety of different libraries and software packages into one place.
  • Automates your work by benefiting from thousands of command-line-based tools and making it more effective for you to work.
  • Install and learn practical Python scripts on your local iMac computer.
  • Setup a testing and development environment for your software development.
See also  How To Use Fake ID

System Requirements

You will need some specific system requirements and personal familiarity skills in the macOS Terminal, which you will be using to install Homebrew. And before that, you should install Apple’s Xcode development software which some Homebrew packages need as a dependency. The minimum specifications you need to install Homebrew on a Mac are the following:

  • macOS Mojave (10.14) or later, the previous versions are limited supported.
  • Apple Silicon CPU 1, or a 64-bit Intel CPU.
  • Command Line Tool (CLT) for Xcode.
  • Availability and knowledge of the bourne-compatible shell for installation and using bash or zsh.
  • Internet connection and administrative access.

How to install Homebrew

The official Homebrew website tells that you need to run this command to get started:

/usr/bin/ruby -e “$(curl -fsSL” 

Homebrew will automatically install macOS. Once you press Enter, Brew will install and download the latest code and deploy it:

The simple and clever thing about Homebrew is that in the future, Brew will auto-update itself, so you’re pretty much guaranteed to be running the latest and efficient code.

What is the meaning of this error?

After downloading and installing, if you receive a “brew command not found” error, it might be possible that the brew executable binary is in the wrong directories listed in your PATH environment variable. 

Environment variables are system variables accessible by all processes and users operating under the Operating System (OS) such as Windows, macOS, and Linux. For example, environment variables can be used to store values system-wide. PATH is the most common environment variable. It keeps a list of directories that are searched for executable files.

Here are some of the solutions that you can try to remove the error:

Software issue

You might be using outdated software that is causing this problem if you are seeing this:

$ brew upgrade

Error: undefined method `include?’ for nil:NilClass

Then report this bug:

/usr/local/Library/Homebrew/formula.rb:393:in `canonical_name’

/usr/local/Library/Homebrew/formula.rb:425:in `factory’


/usr/local/Library/Contributions/examples/brew-upgrade.rb:7:in `map’


/usr/local/bin/brew:46:in `require’

/usr/local/bin/brew:46:in `require?’


This happens because an old version of the upgrade command is hanging around for some reason. The fix:

See also  How to get past chegg paywall? How to bypass chegg blur?

cd “$(brew –repository)/Library/Contributions/examples”

git clean -n #, if this doesn’t list anything that you want to keep. Then try using

git clean -f #; this will remove any untracked files stored in the directory and solve the problem.

Reinstall the Homebrew

When software does not work as intended, deleting and reinstalling it from scratch can be a solution. For example, there might be a problem that occurred while the software was being downloaded. However, to properly delete the Homebrew application, you must use its official script by opening up a Terminal window and running.

/bin/bash -c “$(curl -fsSL

The command above is referred from the Homebrew official Github repo. Once the uninstall process has been completed, head over to Homebrew’s official website and carefully copy and paste the one-line installation command and paste it into Terminal. Sometimes while copying, you may have copied some extra words included in the script and cause a problem.

/bin/bash -c “$(curl -fsSL”

The Homebrew installer is now recently reprogrammed in Bash to ensure compatibility with maximum devices. That is the reason that you are observing /bin/bash instead of ruby. 

Add Brew to PATH 

The Homebrew installer automatically adds Brew to PATH. Still, sometimes, the process may have been interrupted and cause “brew: command not found.” It can also happen that Brew is in the correct directory but not installed correctly and variable is not configured correctly:

  • To correct it, run this command in your Mac environment variable.

echo ‘export PATH=”/usr/local/bin:$PATH”‘ >> ~/.bash_profile

Depending on which directory brew was installed, you might have to replace export as well.


with exportPATH=$PATH:/opt/homebrew/bin

  • Now we need to activate the changes. Type this command to start and try drawing doctor again:

source .bash_profile

Alternatively, suppose you have already configured the environment variable. In that case, you can use this command to see if the configuration is correct or not.

/usr/bin/open ~/.bash_profile 

Try running these scripts for brew command validation:

  • code2care@mac % brew –version
  • Homebrew 3.0.0
  • Homebrew/homebrew-core (git revision f1b2a2; last commit 2021-02-10)
  • code2care@mac / % brew help

Example usage:

brew search [TEXT|/REGEX/]

brew info [FORMULA…]

brew install FORMULA…

See also  How To Fix A Chromebook Screen That Has Lines?

brew update

brew upgrade [FORMULA…]

brew uninstall FORMULA…

brew list [FORMULA…]


brew config

brew doctor

brew install –verbose –debug FORMULA


brew create [URL [–no-fetch]]

brew edit [FORMULA…]

Further help:

brew commands

brew help [COMMAND]

man brew

Wrong Directory

Another error is possible if you have installed the Brew in /usr/local/bin. You can try installing /usr/local/bin/brew doctor to remove brew command not found error. To fix this error permanently, alter your bash profile by adding the following line:

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

Check if XCode is installed or not to ensure no errors in the process.

gcc –version

ruby -e “$(curl -fsSL”

brew doctor

brew update

If you want the exact instruction update, then click here.

nano ~/.profile

If that the above command doesn’t help, then add these lines:

export PATH=”$HOME/.linuxbrew/bin:$PATH”

export MANPATH=”$HOME/.linuxbrew/share/man:$MANPATH”

export INFOPATH=”$HOME/.linuxbrew/share/info:$INFOPATH”

After running these commands, save the file:

Ctrl + X  then Y then Enter. Then render the changes:

source ~/.profile

For the error “command not found: brew”

  • Make sure you’ve installed Brew with this, and it is installed.

/bin/bash -c “$(curl -fsSL”

  • Then follow the steps shown on the command line. It should show something like this.

 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 first line on the same terminal window, then hit enter echo ‘eval $(/opt/homebrew/bin/brew shellenv)’ >> /Users/$USER/.zprofile
  • Then Copy and paste the last line on the same terminal window, then hit enter eval $(/opt/homebrew/bin/brew shellenv)

Finally, you should be able to use brew help. If that works, it means that Brew is finally appropriately installed and running from ZSH without any issues. 


After reading this article, you should know how to remove the command not found after installing Brew on your device. There are several possible reasons why this error is popping up. It can be installed in the wrong directory or any problem in Xcode. Try reinstalling the software and sure to delete Brew completely. If all else fails, add Brew to the PATH variable, which can help in removing this error.