安装brew后我得到`命令not found:brew`

时间:2016-04-15 21:44:09

标签: macos terminal homebrew

➜  ~ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
-e:77: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040677
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
The current contents of /usr/local are bin CODEOFCONDUCT.md etc git lib Library LICENSE.txt munki README.md sbin share .git .github .gitignore
➜  ~ brew install maven
zsh: command not found: brew

13 个答案:

答案 0 :(得分:88)

我对MacOS的大苏尔类似的问题(11.0.1)。在我的情况自制保存在/opt/homebrew/,而不是在/usr/local/...

因此,我增加

export PATH=/opt/homebrew/bin:$PATH

到我主目录中的 .zshrc 文件,并且 ZSH shell 能够找到 brew 命令。

答案 1 :(得分:57)

对于这个错误zsh: command not found: brew

  1. 确保您已经安装了 Brew(等待安装完成)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)
  1. 然后按照命令行上显示的NEXT STEPS,它应该显示如下
==> Next steps:
- 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)
  1. 将第一行复制并粘贴到同一终端窗口中,然后按 Enter 键
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/$USER/.zprofile
  1. 然后将最后一行复制并粘贴到同一终端窗口中,然后按 Enter 键
eval $(/opt/homebrew/bin/brew shellenv)

最后,您应该可以使用 brew help,如果可以使用,则意味着 brew 已正确安装并从 ZSH 运行。

答案 2 :(得分:23)

Homebrew已安装在您的计算机上。你需要修改你的PATH:

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

或从其来源执行brew

/usr/local/bin/brew install maven

答案 3 :(得分:6)

这是我做的步骤...

1.安装自制软件

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

2.运行 brew help 并查看它是否正常工作...如果显示错误“zsh: command not found: brew”,请继续操作。

  1. 将路径更改为:
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/"YOUR USER NAME"/.zprofile

记得把“USER NAME”改成你的, 然后输入:

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

成功运行这些命令后,输入“brew help”以查看是否一切正常。

答案 4 :(得分:4)

在我的 MacBook (macOS Big Sur V 11.0.1) 中安装 Homebrew 后,我遇到了同样的问题。

安装后,在控制台它会说应该做什么,

==> Next steps:
- Add Homebrew to your PATH in /Users/samme/.zprofile:
    echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/samme/.zprofile
    eval $(/opt/homebrew/bin/brew shellenv)
- Run `brew help` to get started

依次执行以上两条命令,会将brew命令添加到PATH中。

答案 5 :(得分:3)

在 Apple M1 的 fish shell 中,我必须将 /opt/homebrew/bin 添加到 fish_user_paths 全局环境。我必须手动执行此操作,因为 set -U fish_user_paths /opt/homebrew/bin $fish_user_paths 得到了

<块引用>

set: 通用变量 'fish_user_paths' 被同名的全局变量遮蔽。

答案 6 :(得分:2)

只需在您的主目录中添加 export PATH=/opt/homebrew/bin:$PATH

如果需要重新启动或重新打开您的终端

答案 7 :(得分:2)

检查以下链接,您可以在那里设置 Homebrew (brew) 命令,并在 .zshrc 文件中设置永久设置路径

How to install homebrew on M1 mac

答案 8 :(得分:1)

确保先安装brew

E, [<date> #16918] ERROR -- #<Bunny::Session:0x... guest@localhost:5672, vhost=/, addresses=[localhost:5672]>: Cannot open a channel: max number of channels on connection reached. Connection channel_max value: 2047

答案 9 :(得分:0)

可能会迟到,但肯定会有所帮助。您必须首先安装brew。只需运行以下命令即可:

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

答案 10 :(得分:0)

如果您使用 WSL2,请确保遵循 linuxbrew 的最终 linux installation instructions

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

答案 11 :(得分:0)

转到官方Homebrew site

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

后续步骤:

test -d ~/.linuxbrew && eval $(~/.linuxbrew/bin/brew shellenv)
test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile
echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile

试试:brew install hello

答案 12 :(得分:0)

基本上你的自制软件保存在 /opt/homebrew/ 中,而不是 /usr/local/.... 路径

在您的主目录中打开 .bash_profile 并添加:

export PATH=/opt/homebrew/bin:$PATH

并重新启动终端。您将启动并运行它。