Why does my brew installation not work?
Solution 1:
"Command not found" indicates that the brew
binary isn't on one of the directories listed in your PATH environment variable. To check what your path is currently, run echo $PATH
. By default, brew installs to /usr/local/bin
. To set the path permanently, you should edit your ~/.bashrc
file to contain the line export PATH="/usr/local/bin:$PATH"
.
On Aplle Silicon machines brew by default install path is /opt/homebrew/bin
Solution 2:
the -bash: brew: command not found
error means that it didn't find the brew
environment variable on your Mac.
The correct environment configuration in .bash_profile
file should be like this:
export PATH="/usr/local/bin:$PATH"
So if you haven't config the brew
environment variable, the correct step to config the brew
environment variable on your Mac is:
-
add the environment variable to your mac, the correct command is:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
-
Now we need to activate the changes. Type this command to activate and try
drew doctor
again:source .bash_profile
Or if you had config the environment, you can use this command to open the file to check if the environment configuration is correct:
/usr/bin/open ~/.bash_profile
and then fix it to the correct text and then save and quit.
-
Don't forget to activate your changes also. Still this command:
source .bash_profile
Solution 3:
I had the same problem—installed brew, used it, but now it doens't work, ie, brew
command not recognized anymore.
The context of my brew-not-recognized-anymore problem is a bit more specific: I'm using iTerm instead of Terminal, I installed brew in the standard way to the standard place, I used brew to install zsh and oh-my-zsh, and at that point the brew command stopped working.
I wasn't able to find the solution to my subset of the brew-not-recognized-anymore problem anywhere, so I'm posting the solution in case anyone else has this sort of brew-not-recognized-anymore problem.
Adding this to my .zshrc
solved the problem on a machine with Apple M1 CPU:
eval $(/opt/homebrew/bin/brew shellenv)
Note that this is not the same as adding to the PATH variable. The brew command is indeed located in those standard locations listed in other solutions. It turned out not to be a PATH variable thing that was causing this subset of the brew-not-recognized-anymore problem.
Solution 4:
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<yourusername>/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
This code works for me on a MacBook Pro M1.
Solution 5:
Might be that you just never downloaded.. I made that mistake. Thought I'd downloaded right, but found out I hit something other then return when it says to "press return to continue or any other key to cancel"