安装HomeBrew步骤在我的老博客写过,目前国内环境中安装会出现标题所述的错误:
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
解决方案一:保存文件
常规网上的方法都是用链接里的文件保存(install.rb)之后执行ruby的方法。
若根据参考链接里的最高赞里的链接进行保存文件:
https://raw.githubusercontent.com/Homebrew/install/master/install
现在此链接已经失效,网页内容为:
#!/usr/bin/ruby
STDERR.print <<EOS
Warning: The Ruby Homebrew installer is now deprecated and has been rewritten in
Bash. Please migrate to the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
EOS
Kernel.exec "/bin/bash", "-c", '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"'
所以目前保存文件的链接应为:
https://raw.githubusercontent.com/Homebrew/install/master/install.sh
可能出错的注意点
保存了install.rb文件后,终端中进入相应目录(cd),报错:
Traceback (most recent call last):
ruby: no Ruby script found in input (LoadError)
解决方案2:使用命令安装
根据我在StarkOverflow上的提问,根据参考链接3中的回答:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
使用此命令即可输入密码并安装。
参考链接
Homebrew installation on Mac OS X Failed to connect to raw.githubusercontent.com port 443