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

当前回答

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

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

或者从起始点执行brew:

/usr/local/bin/brew install maven

其他回答

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

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

或者从起始点执行brew:

/usr/local/bin/brew install maven

确保先安装brew

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

在我的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)"

可能会迟到,但肯定会有帮助。你必须首先安装brew。只要运行下面的命令就可以了:

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

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

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

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

sudo nano /etc/paths

粘贴

/opt/homebrew/bin:$PATH

保存并关闭