1.打开终端
2 移除现有 Ruby 默认源 输入以下指令
$gem sources --remove https://rubygems.org/
3.使用新的源 输入以下指令
$gem sources -a https://ruby.taobao.org/
4.验证新源是否替换成功 输入以下指令
$gem sources -l
// 替换成功
*** CURRENT SOURCES ***
https://ruby.taobao.org/
5.安装cocoapPods
$sudo gem install cocoa pods
苹果系统升级
OS X EL Capitan
后改为 :
$sudo gem install -n /usr/local/bin 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.1.gem (100%)
ERROR: Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
出现错误:
ERROR: Error installing cocoapods:
activesupport requires Ruby version >= 2.2.2.
解决方案 :
1、安装 RVM baby 版本管理器 :
$curl -L get.rvm.io | bash -s stable
等安装完成 出现下面这行提示以下:
In case of problems: https://rvm.io/help and https://twitter.com/rvm_io
执行:
$source ~/.bashrc
$source ~/.bash_profile
测试是否安装正常:
$rvm -v
提示以下:
rvm 1.27.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
2、用RVM升级Ruby查看当前ruby版本
$ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
现在的ruby版本是2.0.0的,安装cocoa pods需要的最低版本是2.2.2的
输入以下命令显示所有ruby版本
$rvm list known
# 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]
# GoRuby
goruby
# Topaz
topaz
# MagLev
maglev[-head]
maglev-1.0.0
# Mac OS X Snow Leopard Or Newer
macruby-0.10
macruby-0.11
macruby[-0.12]
macruby-nightly
macruby-head
# IronRuby
ironruby[-1.1.3]
ironruby-head
$rvm install 2.2.2
安装ruby2.2.2需要一段时间,安装期间记得按回车键,安装成功后继续安装cocoapods.
4.验证新源是否替换成功 输入以下指令