根据Homebrew网站,要安装它,我需要输入:
brew install wget
我得到一个错误消息:
-bash: brew: command not found
找到了这个答案。然而,问题是我在/usr/local/bin中没有看到brew。
我在.bashrc文件中添加了下面这行代码
export PATH=/usr/local/bin:$PATH
仍然得到命令未找到错误。
如何在macOS上安装Homebrew ?
根据Homebrew网站,要安装它,我需要输入:
brew install wget
我得到一个错误消息:
-bash: brew: command not found
找到了这个答案。然而,问题是我在/usr/local/bin中没有看到brew。
我在.bashrc文件中添加了下面这行代码
export PATH=/usr/local/bin:$PATH
仍然得到命令未找到错误。
如何在macOS上安装Homebrew ?
当前回答
如果运行后仍然报错,
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后尝试从https://developer.apple.com/download/more/下载并安装命令行工具,适用于特定的Mac os和Xcode版本。
然后试着跑,
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然后
brew install node
其他回答
您可以使用以下命令安装brew。
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
然而,当使用这个你会得到警告,它购买自制安装程序现在已弃用。建议改用Bash。
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
下面是一个将自制程序安装程序包装在bash函数中的版本,可以从部署脚本中运行:
install_homebrew_if_not_present() {
echo "Checking for homebrew installation"
which -s brew
if [[ $? != 0 ]] ; then
echo "Homebrew not found. Installing..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Homebrew already installed! Updating..."
brew update
fi
}
另一个函数将安装一个自制公式,如果它还没有安装:
brew_install () {
if brew ls --versions $1 > /dev/null; then
echo "already installed: $1"
else
echo "Installing forumula: $1..."
brew install $1
fi
}
一旦你定义了这些函数,你可以在你的bash脚本中像下面这样使用它们:
install_homebrew_if_not_present
brew_install wget
brew_install openssl
...
在终端中添加以下内容,单击“enter”,然后按照终端中的说明操作。/usr/bin/ruby -e "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果您在代理下,以下命令将不起作用。
ruby -e "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
相反,用户关注
ruby -e "$(curl -x http://DOMAIN%5cUSER_NAME:PASSWORD@PROXY:PORT -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
请注意,我们必须使用%5c而不是“\”同样,如果您的密码有任何特殊字符,请将其替换为unicode,例如@使用%40 参考本unicode
用你自己的参数替换上面的命令
域名-你的域名
USER_NAME—您的用户名
PASSWORD -密码
Proxy - 10.10.10.10
端口- 8080
在一个开箱即用的MacOS High Sierra 10.13.6
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
给出以下错误:
curl performs SSL certificate verification by default, using a "bundle" of Certificate Authority (CA) public keys (CA certs). If the default bundle file isn't adequate, you can specify an alternate file using the --cacert option. If this HTTPS server uses a certificate signed by a CA represented in the bundle, the certificate verification probably failed due to a problem with the certificate (it might be expired, or the name might not match the domain name in the URL). If you'd like to turn off curl's verification of the certificate, use the -k (or --insecure) option. HTTPS-proxy has similar options --proxy-cacert and --proxy-insecure.
解决方案:只要在你的卷曲选项中添加一个k
$ ruby -e "$(curl -fsSLk https://raw.githubusercontent.com/Homebrew/install/master/install)"