安装RVM
1.将下面粘贴到终端回车.(不要粘贴$,$是代表开始)
$ curl -L https://get.rvm.io |bash -s stable
2.如果出现
$ source ~/.rvm/scripts/rvm
-bash: $: command not found
bogon:~ hushuangfei$ $ source~/.rvm/scripts/rvm
-bash: $: commandnot found
bogon:~ hushuangfei$ 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 43 0 0:00:04 0:00:04 --:--:-- 43
100 22721 100 22721 0 0 3849 0 0:00:05 0:00:05 --:--:-- 19757
Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz
Downloadinghttps://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc
curl: (28) Connection timed out after 30003 milliseconds
Could not download'https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc'.
curl returned status '28'.
Upgrading the RVM installation in /Users/hushuangfei/.rvm/
RVM PATH line found in /Users/hushuangfei/.mkshrc/Users/hushuangfei/.profile /Users/hushuangfei/.bashrc/Users/hushuangfei/.zshrc.
RVM sourcing line found in/Users/hushuangfei/.profile /Users/hushuangfei/.bash_profile/Users/hushuangfei/.zlogin.
Upgrade of RVM in /Users/hushuangfei/.rvm/ is complete.
# hushuangfei,
#
# Thank you for using RVM!
# We sincerely hope that RVM helpsto make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
In case of problems: http://rvm.io/helpand https://twitter.com/rvm_io
Upgrade Notes:
* No new notes to display.
这样就表示成功了。
2.1.如果出现
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 184 100 184 0 0 43 0 0:00:04 0:00:04 --:--:-- 45
100 22721 100 22721 0 0 4149 0 0:00:05 0:00:05 --:--:-- 155k
Downloading https://github.com/rvm/rvm/archive/1.26.11.tar.gz
Downloadinghttps://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.26.11/1.26.11.tar.gz.asc',
but no GPG software exists to validate it, skipping.
Upgrading the RVM installation in /Users/hushuangfei/.rvm/
RVM PATH line found in/Users/hushuangfei/.mkshrc /Users/hushuangfei/.profile/Users/hushuangfei/.bashrc /Users/hushuangfei/.zshrc.
RVM sourcing line found in/Users/hushuangfei/.profile /Users/hushuangfei/.bash_profile/Users/hushuangfei/.zlogin.
Upgrade of RVM in /Users/hushuangfei/.rvm/ is complete.
# hushuangfei,
#
# Thank you for using RVM!
# We sincerely hope that RVM helpsto make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
In case of problems: http://rvm.io/helpand https://twitter.com/rvm_io
Upgrade Notes:
* WARNING: You have '~/.profile'file, you might want to load it,
to do that add the followingline to '/Users/hushuangfei/.bash_profile':
source ~/.profile
* No new notes to display.
修改则需要添加在终端中添加下面语句,再回车
echo "source ~/.profile" >> ~/.bash_profile
3. 载入 RVM 环境
$ source ~/.rvm/scripts/rvm
4. 检查一下是否安装正确:输入命令 rvm -v ,如果正确会列出RVM版本如下所示:
$ rvm –v
显示:
A RVM version 1.26.10 (latest) is installed yet 1.25.28 (stable) isloaded.
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 安装 Ruby 环境
RVM 装好以后,需要执行下面的命令将指定版本的 Ruby 设置为系统默认版本
$ rvm 2.0.0 --default
同样,也可以用其他版本号,前提是你有用 rvm install 安装过那个版本
测试是否正确
lihuifengdeMacBook-Pro:~ lihuifeng$ ruby -v
ruby 2.0.0p481(2014-05-08 revision 45883) [x86_64-darwin13.1.0]
lihuifengdeMacBook-Pro:~lihuifeng$ gem -v
2.2.2
这有可能是因为Ruby的默认源使用的是cocoapods.org,国内访问这个网址有时候会有问题,网上的一种解决方案是将远替换成淘宝的,替换方式如下:
$gem source -rhttps://rubygems.org/
$ gem source -a https://ruby.taobao.org
lihuifengdeMacBook-Pro:~lihuifeng$ gem source -r https://rubygems.org/
https://rubygems.org/removed from sources
lihuifengdeMacBook-Pro:~lihuifeng$ gem source -a https://ruby.taobao.org
https://ruby.taobao.orgadded to sources
要想验证是否替换成功了,可以执行:
$ gem sources -l
正常的输出结果:
lihuifengdeMacBook-Pro:~lihuifeng$ gem sources -l
*** CURRENTSOURCES ***
这样就代表安装好了