Mac 安装 Homebrew 出错 Failed during: git fetch origin master:refs/remotes/origin/master --tags --force

今天在 Mac 装 Homebrew 遇到了一个问题,在网上找了大量解决方案,做个总结。

Mac 版本 High Sierra 10.13.6。

问题描述

  • 在 Mac 终端输入了 Homebrew 官网给的安装指令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 结果安装到最后出现了错误:
fatal: unable to access 'https://github.com/Homebrew/brew/': Could not resolve host: github.com
Failed during: git fetch origin master:refs/remotes/origin/master --tags --force
  • 网上都说是网不通,可是我也挂着ss,应该不是这个问题,很多解决方法是修改成镜像的链接,不过貌似都不见效。试着在终端 ping 了一下 GitHub 的地址:
ping github.com 
  • 结果出现了下面这个结果,还真是网不通。
ING github.com (13.250.177.223): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3

解决方案

  • 修改 host 配置,在终端中输入下列指令,打开编辑文件。
sudo vi /etc/hosts
  • 按 s 进入编辑模式,在最下面添加 192.30.253.113 github.com
  • 按control + c 保存,接着按:wq退出即可。
  • 再次尝试在终端 ping github.com,发现已经成功了。
PING github.com (192.30.253.113): 56 data bytes
64 bytes from 192.30.253.113: icmp_seq=0 ttl=49 time=351.766 ms
64 bytes from 192.30.253.113: icmp_seq=1 ttl=49 time=388.017 ms
64 bytes from 192.30.253.113: icmp_seq=2 ttl=49 time=391.047 ms
64 bytes from 192.30.253.113: icmp_seq=3 ttl=49 time=408.031 ms
  • 接着继续在终端输入官网的安装指令,就能安装成功了。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

常见问题

  • 如果在安装过程中出现以下情况,就是网不通,再次输入官网安装指令即可。
error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: The remote end hung up unexpectedly

猜你喜欢

转载自www.cnblogs.com/divebombchen/p/10491844.html
今日推荐