cocoapods:安裝/更新Ruby環境教程

簡介

有時候在安裝cocoapods時會產生以下錯誤git

ERROR:  Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
  • 1

這就說明,你的Ruby環境須要升級更新, 我以mac OS 10.11 下更新ruby方法爲例, 說一說更新Ruby環境的詳細步驟.github

緣由和方案

在安裝cocoapods過程當中提示須要Ruby的版本在2.2.2以上,而目前使用的Ruby版本是Mac系統自帶的1.8.7。因此須要對Ruby進行升級。如下是安裝Ruby的三種方法: 
1.下載ruby源代碼,編譯,安裝 
2.使用發行版自帶的安裝包,安裝 
3.使用 rvm安裝shell

經過rvm安裝Ruby詳細步驟

這裏仍是推薦你們經過rvm對Ruby進行升級的.ruby

1>安裝 ram 
RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem庫管理(gemset)bash

$ curl -L get.rvm.io | bash -s stable

這裏寫圖片描述

2>加載文件, 測試是否安裝正常(按照提示操做)curl

$ 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.

 

輸入命令:ui

$ rvm reload $ rvm -v

這裏寫圖片描述

4>查看當前ruby版本 ,獲取rvm 列表url

$ ruby -v $ rvm list known 

這裏寫圖片描述

5>安裝ruby可能出的錯誤 (若未出錯, 請跳過進入第6步)spa

$ rvm install 2.3
  • 1

錯誤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)"

這裏寫圖片描述

6>從新安裝ruby 
安裝完成後, 從新執行安裝cocoapods的命令.

$ rvm install 2.3

7>安裝rails

$ gem install rails

8>卸載ruby方法 
獲取ruby已安裝列表, 而後卸載ruby

$ rvm list $ rvm remove 2.3
相關文章
相關標籤/搜索