系统升级后由于Ruby版本低导致安装Cocoapods 不成功的解决办法

我当前的系统是  macOS  Sierra  版本10.12.1



已经不是第一次安装cocoapods了, 但是今天在自己的mac pro 安装cocoapods 出现了

  Error installing pods:active support requires Ruby version >= 2.2.2


之前安装并没有出现个这个问题, 查了半天资料发现原来是ruby的版本太低了, 需要跟新Ruby. 然后接二连三的坑就出现了.

首先要更新Ruby , 有三种选择
1.下载ruby源代码,编译,安装
2.使用发行版自带的安装包,安装
3.使用 rvm安装

我选择了 rvm安装, 那势必得先安装 rvm

1.RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gems)
$ curl -L get.rvm.io | bash -s stable


2.加载文件, 测试是否安装正常(按照提示操作)
$ source ~/.bashrc 

$ source ~/.bash_profile 

$ source ~/.profile$ rvm -v


3.如果有下面的提示, 请reload rvm
A RVM version 1.27.0 (latest) is installed yet 1.25.23 (stable) is loaded.
Please do one of the following:

  • 'rvm reload'
  • open a new shell
  • 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
  • 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.

输入命令:

$ rvm reload
$ rvm -v


4.查看当前ruby版本 ,获取rvm 列表

$ ruby -v 

$ rvm list known


5.安装ruby可能出的错误 (若未出错, 请跳过进入第6步)

$ rvm install 2.3


4B169ACDB8623A5116B53DA2B24D1F4C.jpg


错误1: 在安装ruby的时候, 可能会如下报错, 提示 Updating system[YourMacName] password required for ‘port -dv self update’

解决:
进行更新:

$ sudo port self update

错误2:
或者你可能遇到如下错误, 原因是需要安装Homebrew.
Error running 'requirements_osx_port_libs_install curl-ca-bundle automake libtool libyaml libffi libksba',showing last 15 lines of /Users/acewill/.rvm/log/1468253599_ruby-2.3.0/package_install_curl-ca-bundle_automake_libtool_libyaml_libffi_libksba.log

解决:
参照stack overflow上的问题Installing RVM: “Requirements installation failed with status: 1.”

需要安装Homebrew , 通过以下命令:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"


以下是我经历的完整步骤:


Last login: Thu Nov  3 08:29:57 on ttys000

99-48-58-38:~ wsh$ rvm help mount

Usage:


    rvm automount

    rvm mount /path/to/ruby [-n {name}]

    rvm mount [-r] {https://url/to/ruby.tar.bz2} [name]



## Mounting local compiled rubies


RVM supports adding rubies compiled by user.


If compiled ruby is already on `PATH` then use:


    rvm automount


If ruby is not on `PATH` and was compiled in `/opt/ruby-1.9.3-p194`,

then both following commands will add it to RVM:


    rvm mount /opt/ruby-1.9.3-p194

    rvm mount /opt/ruby-1.9.3-p194/bin/ruby


RVM will ask user for the name for it, for automation you can use `-n` flag:


    rvm mount /opt/ruby-1.9.3-p194 -n ruby-1.9.3-p194


Which will create `ext-ruby-1.9.3-p194`, the `ext-` prefix is there to

distinguish externally compiled rubies.



## Unmounting locally compiled rubies


Remove the ruby as you would any other:


    rvm remove ext-ruby-1.9.3-p194



## Downloading compiled ruby (since RVM 1.16)


RVM also supports downloading compiled rubies.


You can specify the full url to the binaries:


    rvm mount -r https://rvm.io/binaries/ubuntu/12.04/x86_64/ruby-1.9.3-p194.tar.bz2


It is also possible to download from different url with a name to use:


    rvm mount -r https://some.server/my_ruby-1.9.3-p194.tar.bz2 ruby-1.9.3-p194


Note that the packaged ruby must be using exactly the name that was given as second parameter.


And finally it is possible to just give a name and RVM will build the path for your system:


    rvm mount -r 1.9.3


Assuming the binary is in proper remote path registered with rvm it will be automatically used during installation:


    rvm install 1.9.3


will use https://rvm.io/binaries/ubuntu/12.04/x86_64/ruby-1.9.3-p194.tar.bz2 assuming it is 64bit Ubuntu 12.04.



## List of available builds


RVM automatically detects current platform and displays rubies available for it:


    rvm list remote



## Preparing your own build of ruby


Read more in:


    rvm help prepare


  For additional information please visit RVM's documentation website:


      https://rvm.io/


  If you still cannot find an answer to your question, find

  'wayneeseguin', 'mpapis', 'richo', 'lemoinem' or 'rys' in #rvm on irc.freenode.net:


      http://webchat.freenode.net/?channels=rvm

  

99-48-58-38:~ wsh$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

-bash: gpg: command not found

99-48-58-38:~ wsh$ \curl -sSL https://get.rvm.io | bash -s stable

curl: (35) Server aborted the SSL handshake

99-48-58-38:~ wsh$ curl -L get.rvm.io | bash -s stable

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100   184  100   184    0     0     51      0  0:00:03  0:00:03 --:--:--    51

100 22921  100 22921    0     0  

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值