安装cocoapods出错,ERROR: Could not find a valid gem ‘

19. December 2015 Swift 0

根据官网所述 

sudo gem install cocoapods 

但是出现如下所示错误

ERROR:  Could not find a valid gem ‘cocoapods‘ (>= 0), here is why:

Unable to download data from https://rubygems.org/ – Errno::ECONNRESET: Connection reset by peer –  SSL_connect (https://rubygems.org/quick/Marshal.4.8/cocoapods-0.38.0.gemspec.rz

ERROR:  Possible alternatives: cocoapods

          因为默认所需的下载路径 https://rubygems.org 在国内的访问会有问题

解决方法:

gem sources --remove https://rubygems.org/   // 这一步是将默认的地址移除 
gem sources -a http://ruby.taobao.org/     // 这一步是将淘宝提供的网址加进去
查看gem来源列表:$ gem sources -l
安装Cocoapod:sudo gem install cocoapods
然后就可以根据官网步骤进行了。
另外,还有可能出现[!] You cannot run CocoaPods as root. (CLAide::Help)
退出root账户即可
目前我遇到的问题就这么些。

Leave a Reply

Your email address will not be published. Required fields are marked *