➜  ~ /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

当前回答

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

如果需要重新启动,或者重新打开终端

其他回答

确保先安装brew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

我在macOS Big Sur(11.0.1)上遇到了类似的问题。在我的例子中,homebrew保存在/opt/homebrew/,而不是/usr/local/....

所以我补充道

导出路径= / opt /组装/ bin:美元的道路

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

在您的.zshrc文件中,将路径添加到您的homebrew/bin,无论它可能在哪里。在我的例子中,homebrew安装在我的主目录中。 添加:

export PATH="/<path-to-homebrew-directory>/bin:$PATH"

重新启动终端,让它接收到.zshrc的更改

在我的示例中,我将以下行添加到~/.zshrc

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

也许你已经从homebrew主页上遵循了这一步。

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

所以可能你的系统不能分配路径,所以遵循以下步骤。

sudo nano /etc/paths

粘贴

/opt/homebrew/bin:$PATH

保存并关闭