最近安装 Homebrew 遇到的坑,总结一下。
我的 Mac 版本是 10.13.6。
- 首先安装 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
- 解决方式:
- 试着先在终端 ping github.com
MacBook-Pro:~$ ping github.com PING 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
- 如果 ping 出来是这种结果,就接着看第二步
- 修改 hosts 配置
- 在终端中 sudo vi /etc/hosts 打开编辑文件
- 按 s 进入编辑模式
- 接着在最下面添加 192.30.253.113 github.com
- 按 control + c 保存
- 接着按 :wq 退出,就可以了。
- 在终端 ping github.com
MacBook-Pro:~$ ping github.com PING github.com (