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

当前回答

我将演示来自@Spindizzy的答案:

cd ~ | ls -a
touch .zshrc // if file .zshrc doesn't exists we create it
vim .zshrc

将PATH=/opt/homebrew/bin:$PATH粘贴到那里,保存文件并重启终端。

Vim助手:

1. press "i" to interactive mode in vim, paste:
export PATH=/opt/homebrew/bin:$PATH
2. press "esc" type ":wq" and hit enter

其他回答

下面是我做的步骤。

1.安装自酿酒

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

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

修改路径为:

echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/"YOUR USER NAME"/.zprofile

记得把“用户名”改成你的, 然后输入:

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

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

你的电脑上已经安装了自制软件。你需要像这样修改你的PATH:

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

或者从起始点执行brew:

/usr/local/bin/brew install maven

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

所以我补充道

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

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

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

安装完成后,在控制台中会显示应该做什么:

==>下一步: -将Homebrew添加到/Users/USER/.zprofile中的PATH: echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> /Users/USER/.zprofile . sh Eval $(/opt/homebrew/bin/brew shellenv) -运行“brew help”开始

按顺序执行这两个命令,会将brew命令添加到PATH:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/USER/.zprofile

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

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

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

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