CocoaPods安装/更新报错While executing gem ... (OpenSSL::SSL::SSLError)解决方案
今天给新买的MacBook Pro更新CocoaPods,结果上来就报错,出师不利。
HeinocdeMacBook-Pro:~ Heinoc$ sudo gem update --system Password: Updating rubygems-update ERROR: While executing gem ... (OpenSSL::SSL::SSLError) hostname "gems.ruby-china.org" does not match the server certificate
原因是gem没有认证gems.ruby-china.org的证书,所以添加一下这个源就可以了。
$ gem sources -a http://gems.ruby-china.org/
检测一下结果:
HeinocdeMacBook-Pro:~ Heinoc$ gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org/ http://gems.ruby-china.org/
然后再去更新gem版本即可:
$ sudo gem update --system
附上CocoaPods的安装、更新方法:
1.更新gem系统:
$ sudo gem update --system
2.查看gem源:
$ gem sources -l
注:如果源中有https://rubygems.org/ ,因容易被墙,建议删除,并添加国内淘宝源:
$ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/
3.安装CocoaPods:
$ sudo gem install cocoapods
如果报错While executing gem ... (OpenSSL::SSL::SSLError),则执行:
$ sudo gem install -n /usr/local/bin cocoapods --pre
4.设置pod仓库:
$ pod setup