今天在自己mac 安装cocoapods 出现Error installing pods:activesupport requires Ruby version >= 2.2.2
之前也装过,都没出过这个问题。。
当时蒙了,不太了解这个ruby,网上查了半天资料。最后在stack overflow上找到了一些解决方法。意思就是要更新ruby 的版本 命令行 ruby -v 查看自己的版本,太低。
决定搜索资料 更新这个Ruby。
因为准备在项目中使用,在安装过程中提示需要Ruby的版本在2.2.2以上,而目前使用的Ruby版本是Mac系统自带的2.0.0。所以需要对Ruby进行升级。这里使用RVM对Ruby进行升级,升级过程如下:
1、安装 RVM
RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)
$ curl -L get.rvm.io | bash -s stable
等待一段时间后就可以成功安装好 RVM。
$ source ~/.bashrc
$ source ~/.bash_profile
测试是否安装正常
rvm -v
ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
2、用RVM升级Ruby
#查看当前ruby版本
$ ruby -v
ruby 2.0.0
#列出已知的ruby版本
$ rvm list known
......
[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 2.2.2
rvm install 2.2.2
rvm install 2.2.2
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.11/x86_64/ruby-2.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
About to install Homebrew, press `Enter` for default installation in `/usr/local`,
type new path if you wish custom Homebrew installation (the path needs to be writable for user)
最后出现的这样的结果,然后点击三个enter
安装成功时,出现以下命令:
ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin15]
这时候证明安装成功,可以接下来,继续执行安装cocoapods的命令
sudo gem install cocoapods // 安装cocoapods
pod setup
和安装过程是一样的,再次查看版本
pod --version
接下里就可以直接用cocoapods来管理第三方库了
pod search afn
可能问题不是很多,如有疑惑欢迎随时@或留言!!!谢谢!