ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why: Unable to download ...

安装 cocoapods 报错:
该问题主要是 镜像 的问题:
Mac:~ mac$ sudo gem install -n/usr/local/bin cocoapods
Password:
ERROR:  Could not find a valid gem 'cocoapods' (>= 0), here is why:
          Unable to download data from https://ruby.taobao.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

-----------------------------------------
https://gems.ruby-china.org/ 访问不了
域名改为
https://gems.ruby-china.com/
-----------------------------------------

所以替换 ruby-china 提供镜像,正确的操作是:
$ gem sources --remove https://rubygems.org/
$ gem sources --remove https://ruby.taobao.org/    // 如果安装了淘宝的镜像,也删除

// 等有反应之后再敲入以下命令
$ gem sources -a https://gems.ruby-china.com/

为了验证你的Ruby镜像是并且仅是ruby-china,可以用以下命令查看:
$ gem sources -l

具体效果如下:
192:~ mac$ gem sources --remove https://rubygems.org/
source https://rubygems.org/ not present in cache
192:~ mac$ gem sources --remove https://ruby.taobao.org/ 
https://ruby.taobao.org/ removed from sources
192:~ mac$ gem sources -a https://gems.ruby-china.com/
https://gems.ruby-china.com/ added to sources
192:~ mac$ gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/


192:~ mac$ sudo gem update --system   // 更新一下
Latest version already installed. Done.

$ sudo gem install -n /usr/local/bin cocoapods  // 安装最新版本的 cocoapods

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容