最近作為主力的iMac因?yàn)榘惭b了某個(gè)音頻增強(qiáng)軟件稍走,導(dǎo)致系統(tǒng)無法正常重啟和關(guān)機(jī)皂林,重裝系統(tǒng)后,開發(fā)環(huán)境基本都要重新安裝一遍乱凿,不知道什么問題顽素,從node.js到cocoapods按以往經(jīng)驗(yàn)配置的時(shí)候都出現(xiàn)了問題······本文的緣起就是cocoapods安裝的時(shí)候提示ruby版本需要使用2.2.2以上咽弦!
整理了一上午無果,晚上又搗鼓了一下胁出,居然可以了~
安裝RVM
打開【終端】型型,輸入下面的語句,執(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版本全蝶,使用下面的語句:
$ 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í)行下面的語句闹蒜,使配置文件生效:
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í)行下面的的命令來進(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]
注意
- 有時(shí)候安裝好 RVM绷落,系統(tǒng)仍然無法安裝 Ruby,提示缺少某些必要的庫始苇,例如砌烁,我就需要逐個(gè)安裝下面的庫:
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版本》