最近作为主力的iMac因为安装了某个音频增强软件,导致系统无法正常重启和关机,重装系统后,开发环境基本都要重新安装一遍,不知道什么问题,从node.js到cocoapods按以往经验配置的时候都出现了问题······本文的缘起就是cocoapods安装的时候提示ruby版本需要使用2.2.2以上!
整理了一上午无果,晚上又捣鼓了一下,居然可以了~
安装RVM
打开【终端】,输入下面的语句,执行 RVM 的安装
curl -L https://get.rvm.io | bash -s stable
终端会执行一些内容:
$ 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
注意上面的提示内容:
* 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.
在终端继续执行下面的语句,使配置文件生效:
source ~/.profile
附:RVM 常用命令
$ rvm list known # 列出已知的 Ruby 版本
$ rvm install <version> # 安装指定版本的 Ruby
$ rvm remove <version> # 删除指定版本的 Ruby
$ rvm list # 列出已安装的 Ruby 版本
$ rvm use <version> # 使用指定版本的 Ruby,RVM支持多个 Ruby 版本共存
$ rvm reload # 重启 RVM
安装指定版本或最新版本的 Ruby 环境
执行下面的的命令来进行 Ruby 的安装:
# 首先列出已知的 Ruby 版本
$ rvm list known
# 安装指定版本的 Ruby
$ rvm install 2.2.2
终端会执行安装,期间可能会需要输入用户密码:
$ 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
终端输出版本号:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
注意
- 有时候安装好 RVM,系统仍然无法安装 Ruby,提示缺少某些必要的库,例如,我就需要逐个安装下面的库:
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