Could not find a valid gem 'cocoapods'

在设置Ruby环境时输入

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

遇到下面错误

ERROR: Could not find a valid gem 'cocoapods' (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)

很明显404找不到上面的网址,你复制到浏览器,它会提醒你改成了com结尾,So:

一、删除

gem sources --remove https://gems.ruby-china.org/

二、添加

gem sources -a https://gems.ruby-china.com

三、检查

gem sources -l

如果是

*** CURRENT SOURCES ***
https://gems.ruby-china.com

代表成功,再执行

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

你可能感兴趣的:(Could not find a valid gem 'cocoapods')