【解决】Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please che...

最近更新cocoapods一直失败,提示[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

一开始以为是是网络问题,翻墙,热点,切换网络都失败,google一番,Stack Overflow 提示需要更新openssl

$ which openssl
/usr/bin/openssl

$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

$ brew update

$ brew install openssl

$ brew upgrade openssl

`` If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile

$ which openssl
/usr/local/opt/openssl/bin/openssl

$ openssl version
OpenSSL 1.0.2n  7 Dec 2017

$ brew install rbenv ruby-build

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
$ source ~/.bash_profile

$ rbenv install --list

Available versions:
  1.8.5-p52
  1.8.5-p113
  1.8.5-p114
  1.8.5-p115
  1.8.5-p231
  1.8.6
:
  2.1.0
  2.1.1
  2.1.2
:

$ rbenv install 2.1.0

$ rbenv versions
* system (set by /Users/username/.rbenv/version)
  2.1.0

$ ruby --version
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

$ rbenv global 2.1.0

$ rbenv versions
  system
* 2.1.0 (set by /Users/username/.rbenv/version)

$ ruby --version
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-darwin16.0]

$ gem install cocoapods -n /usr/local/bin

$ which pod
/usr/local/bin/pod

$ pod --version
1.4.0

正常来说,按照上面的步骤更新成功就可以了,但是,终端提示

curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

最后发现原因是raw.githubusercontent.com被墙。

解决方法是更改host之后再更新

解决步骤如下
1、查询真实的ip地址

raw.githubusercontent.com 查询真实的IP地址,现在查到的是 151.101.40.133。

2、终端输入命令,并输入密码

sudo vi /etc/hosts

3、将以下文本放于文字最后

151.101.40.133 raw.githubusercontent.com

4、成功,重新pod install 即可

参考链接

参考链接
对应ip查询

你可能感兴趣的:(【解决】Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please che...)