1.安装 RVM
RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset)
打开控制台输入命令
curl -L get.rvm.io | bash -s stable
控制台执行命令后如下
MiaozdeMacBook-Pro:~ miaoz$ curl -L get.rvm.io | bash -s stable % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 194 100 194 0 0 43 0 0:00:04 0:00:04 --:--:-- 43100 24090 100 24090 0 0 3928 0 0:00:06 0:00:06 --:--:-- 27406Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gzDownloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.ascFound PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc', but no GPG software exists to validate it, skipping. Installing RVM to /Users/miaoz/.rvm/ Adding rvm PATH line to /Users/miaoz/.profile /Users/miaoz/.mkshrc /Users/miaoz/.bashrc /Users/miaoz/.zshrc. Adding rvm loading line to /Users/miaoz/.profile /Users/miaoz/.bash_profile /Users/miaoz/.zlogin. Installation of RVM in /Users/miaoz/.rvm/ is almost complete: * To start using RVM you need to run `source /Users/miaoz/.rvm/scripts/rvm` in all your open shell windows, in rare cases you need to reopen all shell windows.
下载完成后我们执行下上边提示的命令
source /Users/miaoz/.rvm/scripts/rvm
执行完后我们使用rvm -v 验证下是否成功。
2.使用rvm升级ruby
#查看当前ruby版本 $ ruby -v #列出已知的ruby版本 $ rvm list known #安装ruby 2.4.1$ rvm install 2.4.1
MiaozdeMacBook-Pro:~ miaoz$ ruby -v ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
MiaozdeMacBook-Pro:~ miaoz$ rvm list known# MRI Rubies[ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head[ruby-]1.9.1[-p431] [ruby-]1.9.2[-p330] [ruby-]1.9.3[-p551] [ruby-]2.0.0[-p648] [ruby-]2.1[.10] [ruby-]2.2[.7] [ruby-]2.3[.4] [ruby-]2.4[.1] ruby-head# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2# JRubyjruby-1.6[.8] jruby-1.7[.27] jruby[-9.1.13.0] jruby-head# Rubiniusrbx-1[.4.3] rbx-2.3[.0] rbx-2.4[.1] rbx-2[.5.8] rbx-3[.84] rbx-head# Opalopal# Minimalistic ruby implementation - ISO 30170:2012mruby-1.0.0mruby-1.1.0mruby-1.2.0mruby-1[.3.0] mruby[-head]# Ruby Enterprise Editionree-1.8.6ree[-1.8.7][-2012.02]# Topaztopaz# MagLevmaglev[-head] maglev-1.0.0# Mac OS X Snow Leopard Or Newermacruby-0.10macruby-0.11macruby[-0.12] macruby-nightly macruby-head# IronRubyironruby[-1.1.3] ironruby-head
rvm install 2.4.1
作者:Miaoz0070
链接:https://www.jianshu.com/p/f56addf0c870