I have installed Homebrew using:

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Why is the brew command not found?

(base) rags@Rageshs-Mac-mini ~ % brew help
zsh: command not found: brew

My $PATH variable according to the shell:

(base) rags@Rageshs-Mac-mini ~ % echo $path
/Users/rags/opt/anaconda3/bin /Users/rags/opt/anaconda3/condabin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /Library/Apple/usr/bin
  • Why do you have a lower-case "path" variable? Shouldn't it be all caps? I'm suspicious of how your shell environment is set up.
    – Spiff
    Jan 29, 2021 at 12:02
  • Maybe it's case insensitive? Jan 29, 2021 at 13:05
  • There should be some questions asked by the install script, and some output. Can you share that? Also, is there anything installed in /opt/homebrew? If not, then the install didn't work. If there is (and I mean like a LOT of stuff), then the install might have worked but it might have failed to configure your shell properly. You mostly just need add /opt/homebrew/bin to your $PATH in your shell config file (which could be .profile, .bashrc, or .zshrc), like this: stackoverflow.com/questions/11530090/…
    – jimtut
    Jan 29, 2021 at 18:32

1 Answer 1


Homebrew isn't included in your $PATH variable, which is the cause of the shell not finding the brew command.

To fix this, you must edit your shell startup script, .zshrc. The Homebrew installer doesn't make this edit, but rather instructs the user to do it, which you probably missed.

Add the following line to .zshrc:

eval $(/opt/homebrew/bin/brew shellenv)

You can either add it with a text editor or by executing a shell command:

$ echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> $HOME/.zshrc

Now, reload the shell by opening a new shell window and you should be good to go.


The lines in .zshrc are executed each time you open a new shell.

When the shell reaches the line

eval $(/opt/homebrew/bin/brew shellenv)

it will at first execute

/opt/homebrew/bin/brew shellenv

, that is, executing the brew binary, given with its full path, with shellenv provided as an argument. From man brew:

        Print export statements. When run in  a  shell,  this  installation  of
        Homebrew will be added to your PATH, MANPATH, and INFOPATH.

        are also exported to  avoid  querying  them  multiple  times.  Consider
        adding  evaluation  of  this  command's  output  to your dotfiles (e.g.
        ~/.profile, ~/.bash_profile, or ~/.zprofile) with:  eval  $(brew  shel-

Indeed, the output of brew shellenv is:

$ brew shellenv
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";

So in effect, the shell startup script executes eval $(...), with ... replaced by the lines above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.