➜ ~ /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
当前回答
如果您使用的是WSL2,请确保遵循linuxbrew的最终linux安装说明。
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
其他回答
我在macOS Big Sur(11.0.1)上遇到了类似的问题。在我的例子中,homebrew保存在/opt/homebrew/,而不是/usr/local/....
所以我补充道
导出路径= / opt /组装/ bin:美元的道路
到我的主目录中的.zshrc文件,并且ZSH shell能够找到brew命令。
下面是我做的步骤。
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”查看是否一切正常。
确保先安装brew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
在您的.zshrc文件中,将路径添加到您的homebrew/bin,无论它可能在哪里。在我的例子中,homebrew安装在我的主目录中。 添加:
export PATH="/<path-to-homebrew-directory>/bin:$PATH"
重新启动终端,让它接收到.zshrc的更改
我将演示来自@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
推荐文章
- 警告用户/local/mysql/data目录不属于mysql用户
- 崇高的文本从命令行
- 在Mac OS X上使用鼠标聚焦(加上自动提升)
- 我在哪里可以找到Mac OS X Lion的“make”程序?
- 当我没有Mac的时候,在Mac/Safari上测试web应用程序
- 在Mac上安装MySQL后,使用ALTER USER语句重置MySQL root密码
- my.cnf文件在macOS上的位置
- 如何从Mac OS X上卸载MySQL ?
- Git bash错误:无法fork子进程:没有可用的终端(-1)
- 使用grep删除空行
- 查找当前可执行文件的路径,不包含/proc/self/exe
- 我如何安装imagemagick与自制?
- Git在终端提交时打开VIM,但无法返回终端
- 在Mac上安装R -警告消息:设置LC_CTYPE失败,使用“C”
- 为什么cURL返回错误“(23)Failed writing body”?