Mac:升級(jí) Ruby 環(huán)境版本

最近作為主力的iMac因?yàn)榘惭b了某個(gè)音頻增強(qiáng)軟件,導(dǎo)致系統(tǒng)無(wú)法正常重啟和關(guān)機(jī),重裝系統(tǒng)后,開發(fā)環(huán)境基本都要重新安裝一遍,不知道什么問題,從node.js到cocoapods按以往經(jīng)驗(yàn)配置的時(shí)候都出現(xiàn)了問題······本文的緣起就是cocoapods安裝的時(shí)候提示ruby版本需要使用2.2.2以上!
整理了一上午無(wú)果,晚上又搗鼓了一下,居然可以了~

Ruby

安裝RVM

打開【終端】,輸入下面的語(yǔ)句,執(zhí)行 RVM 的安裝

curl -L https://get.rvm.io | bash -s stable

終端會(huì)執(zhí)行一些內(nèi)容:

$ curl -L https://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     95      0  0:00:01  0:00:01 --:--:--    95
100 22865  100 22865    0     0   7255      0  0:00:03  0:00:03 --:--:--  101k
Downloading https://github.com/rvm/rvm/archive/1.27.0.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.27.0/1.27.0.tar.gz.asc',
but no GPG software exists to validate it, skipping.

Upgrading the RVM installation in /Users/您的用戶名/.rvm/
    RVM PATH line found in /Users/您的用戶名/.mkshrc /Users/您的用戶名/.profile /Users/您的用戶名/.bashrc /Users/您的用戶名/.zshrc.
    RVM sourcing line found in /Users/您的用戶名/.profile /Users/您的用戶名/.bash_profile /Users/您的用戶名/.zlogin.
Upgrade of RVM in /Users/您的用戶名/.rvm/ is complete.

# 您的用戶名,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io

Upgrade Notes:

  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/Users/您的用戶名/.bash_profile':

      source ~/.profile

  * No new notes to display.

查看RVM版本,使用下面的語(yǔ)句:

$ rvm -v

注意上面的提示內(nèi)容:

  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/Users/您的用戶名/.bash_profile':

      source ~/.profile

  * No new notes to display.

在終端繼續(xù)執(zhí)行下面的語(yǔ)句,使配置文件生效:

source ~/.profile

附:RVM 常用命令

$ rvm list known   # 列出已知的 Ruby 版本
$ rvm install <version> # 安裝指定版本的 Ruby
$ rvm remove <version> # 刪除指定版本的 Ruby
$ rvm list # 列出已安裝的 Ruby 版本
$ rvm use <version> # 使用指定版本的 Ruby,RVM支持多個(gè) Ruby 版本共存
$ rvm reload # 重啟 RVM

安裝指定版本或最新版本的 Ruby 環(huán)境

執(zhí)行下面的的命令來(lái)進(jìn)行 Ruby 的安裝:

# 首先列出已知的 Ruby 版本
$ rvm list known

# 安裝指定版本的 Ruby
$ rvm install 2.2.2

終端會(huì)執(zhí)行安裝,期間可能會(huì)需要輸入用戶密碼:

$ rvm install 2.2.2
Searching for binary rubies, this might take some time.
Found remote file https://rvm_io.global.ssl.fastly.net/binaries/osx/10.11/x86_64/ruby-2.2.2.tar.bz2
Checking requirements for osx.
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
ruby-2.2.2 - #configure
ruby-2.2.2 - #download
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 6854k  100 6854k    0     0  1292k      0  0:00:05  0:00:05 --:--:-- 1729k
ruby-2.2.2 - #validate archive
ruby-2.2.2 - #extract
ruby-2.2.2 - #validate binary
ruby-2.2.2 - #setup
ruby-2.2.2 - #gemset created /Users/您的用戶名/.rvm/gems/ruby-2.2.2@global
ruby-2.2.2 - #importing gemset /Users/您的用戶名/.rvm/gemsets/global.gems..........-
ruby-2.2.2 - #generating global wrappers........
ruby-2.2.2 - #gemset created /Users/您的用戶名/.rvm/gems/ruby-2.2.2
ruby-2.2.2 - #importing gemsetfile /Users/您的用戶名/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.2.2 - #generating default wrappers........
Updating certificates in '/etc/openssl/cert.pem'.
mkdir: /etc/openssl: Permission denied
mkdir -p "/etc/openssl" failed, retrying with sudo
您的用戶名 password required for 'mkdir -p /etc/openssl': 
and sudo mkdir worked

查看 Ruby 版本:

$ ruby -v

終端輸出版本號(hào):

ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

注意

  1. 有時(shí)候安裝好 RVM,系統(tǒng)仍然無(wú)法安裝 Ruby,提示缺少某些必要的庫(kù),例如,我就需要逐個(gè)安裝下面的庫(kù):
brew install autoconf
brew install autoconf
brew install automake
brew install libtool
brew install apple-gcc42
brew install libyaml
brew install libxslt
brew install libksba
brew install openssl

參考:

《Mac OS X zsh下安裝 rvm 和 ruby 》- 作者:圓旭
《如何在Mac 終端升級(jí)ruby版本》

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容