1.移除现有的Ruby
$gem sources --remove https://rubygems.org/
2.使用淘宝镜像
$gem sources -a https://ruby.taobao.org/
3.验证当前ruby版本
$gem sources -l
成功后提示:
*** CURRENT SOURCES ***
https://ruby.taobao.org/
4.开始安装cocoapods
$sudo gem install cocoapods
这时候提示:
Fetching: i18n-0.7.0.gem (100%)
Successfully installed i18n-0.7.0
Fetching: thread_safe-0.3.5.gem (100%)
Successfully installed thread_safe-0.3.5
Fetching: tzinfo-1.2.2.gem (100%)
Successfully installed tzinfo-1.2.2
Fetching: minitest-5.9.0.gem (100%)
Successfully installed minitest-5.9.0
Fetching: concurrent-ruby-1.0.2.gem (100%)
Successfully installed concurrent-ruby-1.0.2
Fetching: activesupport-5.0.0.gem (100%)
ERROR: Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
这个地方很坑,之前安装cocoapods一直是没有这个问题的,这里提示Ruby版本要大于或等于2.2.2于是查看ruby版本
$ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
查看目前的所有ruby版本:
$rvm list known
如果提示command not found 请先安装rvm
$curl -L get.rvm.io | bash -s stable
如果已安装会列出所有的ruby版本:
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.8]
[ruby-]2.2[.4]
[ruby-]2.3[.0]
[ruby-]2.2-head
ruby-head
# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2
# JRuby
jruby-1.6[.8]
jruby-1.7[.23]
jruby[-9.0.5.0]
jruby-head
# Rubinius
rbx-1[.4.3]
rbx-2.3[.0]
rbx-2.4[.1]
rbx[-2.5.8]
rbx-head
# Opal
opal
# Minimalistic ruby implementation - ISO 30170:2012
mruby[-head]
# Ruby Enterprise Edition
ree-1.8.6
ree[-1.8.7][-2012.02]