`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.

1 Like

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.