`brew: command not found` after first install

What you were trying to do (and why)

Install Homebrew.
Please note that I found and read a similar issue (https://github.com/Homebrew/brew/issues/4243). I used the suggested solution of changing $PATH, and it did not work.

What happened (include command output)

  1. Logged into Admin user.
  2. In the /usr/local directory, followed this direction (https://docs.brew.sh/Installation#untar-anywhere) and ran this command: mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  3. Got a bunch of permission errors (could not scroll back far enough in the terminal to copy them).
  4. Tried again with sudo: sudo mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  5. Typed in brew help, and got -bash: brew: command not found.
  6. Tried this instead to do the install again:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  7. Typed in brew help, and got -bash: brew: command not found.
  8. Checked xcode-select was installed
  9. Tried editing the path: export PATH="/usr/local/bin:$PATH"
  10. Bash still didn’t recognize the brew command.
  11. Tried changing owner a couple of different ways and ran into permission errors:
    • sudo chown -R $USER /usr/local/lib /usr/local/include /usr/local/bin /usr/local/Cellar
    • sudo chown -R $USER $(brew --prefix)/*
  12. Ran the install command again: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  13. Ran sudo chown -R $USER:admin /usr/local. Output: chown: /usr/local: Operation not permitted
  14. brew was still not recognized as a command.
Command output
# When running `brew help`:
 `-bash: brew: command not found`
# When re-running the install:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made writable by user only:
/usr/local/share/zsh
/usr/local/share/zsh/site-functions

Press RETURN to continue or any other key to abort
Password:
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> Downloading and installing Homebrew…
/usr/local/homebrew/.git: Permission denied
Failed during: git init -q
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (or will be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations

fatal: not in a git directory
Failed during: git config --replace-all homebrew.analyticsmessage true
==> Next steps:

What you expected to happen

After I saw Installation successful! in the command output, I expected
brew help to print documentation. Then, after I had tried the path change and owner change, I expected bash to recognize brew.

Step-by-step reproduction instructions (by running brew commands)

Please note that bash would not even recognize brew as a command.
As listed in the answer to a previous question, this is what I did, step-by-step:

  1. Logged into Admin user.
  2. In the /usr/local directory, followed this direction (https://docs.brew.sh/Installation#untar-anywhere) and ran this command: mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  3. Got a bunch of permission errors (could not scroll back far enough in terminal to copy them).
  4. Tried again with sudo: sudo mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
  5. Typed in brew help, and got -bash: brew: command not found.
  6. Tried this instead to do the install again:/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  7. Typed in brew help, and got -bash: brew: command not found.
  8. Checked xcode-select was installed
  9. Tried editing the path: export PATH="/usr/local/bin:$PATH"
  10. Bash still didn’t recognize the brew command.
  11. Tried changing owner a couple of different ways:
    • sudo chown -R $USER /usr/local/lib /usr/local/include /usr/local/bin /usr/local/Cellar
    • sudo chown -R $USER $(brew --prefix)/*
  12. Ran the install command again: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  13. Ran sudo chown -R $USER:admin /usr/local. Output: chown: /usr/local: Operation not permitted
  14. brew was still not recognized as a command.

Output of brew config and brew doctor commands

`-bash: brew: command not found`

Run sudo chown -R $USER:admin /usr/local/*

And then try the installer again. Chown is blocked on /usr/local by SIP.

2 Likes

Thanks; before I got this message I tried running the install command again: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" and everything worked.

1 Like

Hello, I have some trouble about my Brew because my terminal it does not recognize the brew and put the code line that you indicated sudo chown -R USER: admin / usr / local / *. But the word (base) appeared on the first line of the terminal at the start (base) Users-MacBook-Pro: ~ user . How can I go back to how I was without this word (base)? since I don’t know very well what the expression chown -R $ USER means: admin / usr / local / *. I would appreciate help on this. Cheers

These are shell settings and usually represent the local directory or git branch. This is just information and doesn’t actually impact the functions in your terminal.

sudo chown -R $USER:admin /usr/local/*

  • sudo means “run the next code as another user” with the default being the administrator user. That’s what we’re using it for here.

  • chown is the command to change the owner of a directory or file.

  • -R means this directory and all directories contained in it are getting a new owner.

  • $USER:admin is the new owner and group of the file/directory. With $USER being replaced by the current username when you run this command.

  • /usr/local/* this means all files and directories in /usr/local. This is the location where homebrew installs and is expected to be owned by the user for homebrew to work.

Captura de pantalla 2020-04-28 a las 9.05.27 PM For some reason impact and appears this word (base) in the beginning, maybe for the -R of a new owner?. How i can come back as a default of fabric?. Greetings!

That’s not a homebrew related question at all, I have no idea what you did to do that, nor is it related to homebrew.

That´s ok I understand I just type the line code that you put: sudo chown -R $USER:admin /usr/local/* and this happens. Best

Resolved my issue :100:

HI i tried the command

/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”

but i get the error saying invald group: MyUser:admin

I only have one main user in my linux system running pop os 20.04

the /bin/bash installs succcesfully but after installing it i get the error saying brew command not found

Hello, I still keep having a problem to install homebrew. Like some others - it dont finish, want to press RETURN and then “brew: command not found”.

I have tried some advices, but it didnt get better.

I have installed VirtualBox and program SAS because school in the same folder and I dont know, if this can be problem, because everytime after I was trying to install hbrew, I cant run the SAS.

Could be this the problem? Mabye I didnt catch all the advices I have read and tried, I was scared to use sudo yet.

Could someone to help me please? Thanks

brew: command not found generally means one of two things:

  1. The Homebrew install didn’t finish correctly, i.e. there were clearly-stated errors.
  2. The Homebrew bin directory (/usr/local/bin on macOS, /home/linuxbrew/.linuxbrew/bin on Linux) isn’t in your shell’s PATH.

In the first case, you’ll have to address those errors to get Homebrew working. If you don’t know what those errors mean, post the exact text; “it don’t finish” tells us nothing about exactly what happened on your system.

In the second case, you need to edit your .profile as stated in the instructions you see at the end of the install, then start a new shell session (or log out and back in again). File changes generally won’t magically update your current session.

If it’s something else, post the exact output, otherwise no one can help.

Maybe, maybe not. The devil’s in the exact details, and you haven’t provided much. Command output is far more useful than vague stories when solving pretty much all tech problems, including Homebrew’s.

Ok then:

MacBook-Pro:~ USER$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Password:

**==>** **This script will install:**

/usr/local/bin/brew

/usr/local/share/doc/homebrew

/usr/local/share/man/man1/brew.1

/usr/local/share/zsh/site-functions/_brew

/usr/local/etc/bash_completion.d/brew

/usr/local/Homebrew

**==>** **The following existing directories will be made group writable:**

/usr/local/bin

/usr/local/include

/usr/local/lib

/usr/local/share

/usr/local/lib/pkgconfig

/usr/local/share/man

/usr/local/share/man/man1

/usr/local/share/man/man3

/usr/local/share/man/man5

/usr/local/share/man/man7

**==>** **The following existing directories will have their owner set to** **evina** :

/usr/local/bin

/usr/local/include

/usr/local/lib

/usr/local/share

/usr/local/lib/pkgconfig

/usr/local/share/man

/usr/local/share/man/man1

/usr/local/share/man/man3

/usr/local/share/man/man5

/usr/local/share/man/man7

**==>** **The following existing directories will have their group set to** **admin** :

/usr/local/bin

/usr/local/include

/usr/local/lib

/usr/local/share

/usr/local/lib/pkgconfig

/usr/local/share/man

/usr/local/share/man/man1

/usr/local/share/man/man3

/usr/local/share/man/man5

/usr/local/share/man/man7

**==>** **The following new directories will be created:**

/usr/local/etc

/usr/local/sbin

/usr/local/var

/usr/local/opt

/usr/local/share/zsh

/usr/local/share/zsh/site-functions

/usr/local/var/homebrew

/usr/local/var/homebrew/linked

/usr/local/Cellar

/usr/local/Caskroom

/usr/local/Homebrew

/usr/local/Frameworks

Press RETURN to continue or any other key to abort

the same, what happened to many others, installation is not finished.

and I have made a mistake before, the sas folder is not there

MacBook-Pro:~ USER$ ls -a /usr/local/
.				include
..				lib
.com.apple.installer.keep	remotedesktop
bin				share
git

Did you press the return key at the point where you took the snippet?

Press RETURN to continue or any other key to abort

Thanks I check it out I had been mistaking what one is the return key in here.