ruby版本升级,转帖

参考连接:https://blog.csdn.net/qq_26440803/article/details/82717244

在线安装ruby

使用yum在线安装ruby,安装的版本为2.0.0。

yum install ruby

ruby -v

添加ruby仓库

添加aliyun镜像并检测Ruby版本

gem sources -a http://mirrors.aliyun.com/rubygems/

ruby -v

安装RAM

RAM(Ruby Version Manager )是一款RAM的命令行工具,可以使用RAM轻松安装,管理Ruby版本。RVM包含了Ruby的版本管理和Gem库管理(gemset)

可以使用如下命令进行安装RAM:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

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

出现如下信息代表安装成功:

GPG verified '/home/sidian/.rvm/archives/rvm-1.29.10.tgz'
Installing RVM to /home/sidian/.rvm/
    Adding rvm PATH line to /home/sidian/.profile /home/sidian/.mkshrc /home/sidian/.bashrc /home/sidian/.zshrc.
    Adding rvm loading line to /home/sidian/.profile /home/sidian/.bash_profile /home/sidian/.zlogin.
Installation of RVM in /home/sidian/.rvm/ is almost complete:

  * To start using RVM you need to run `source /home/sidian/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM ????
Please consider donating to our open collective to help us maintain RVM.

????  Donate: https://opencollective.com/rvm/donate

更新配置文件,使其立马生效:

source /etc/profile.d/rvm.sh 我是执行这个`source /home/sidian/.rvm/scripts/rvm`

查看RVM版本信息,如果可以代表安装成功。

rvm -v

接下来查看Ruby版本:

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[.10]

[ruby-]2.3[.7]

[ruby-]2.4[.4]

[ruby-]2.5[.1]

[ruby-]2.6[.0-preview2]

ruby-head

# for forks use: rvm install ruby-head-<name> --url https://github.com/github/ruby.git --branch 2.2

# JRuby

jruby-1.6[.8]

jruby-1.7[.27]

jruby-9.1[.17.0]

jruby[-9.2.0.0]

jruby-head

# Rubinius

rbx-1[.4.3]

rbx-2.3[.0]

rbx-2.4[.1]

rbx-2[.5.8]

rbx-3[.100]

rbx-head

# TruffleRuby

truffleruby[-1.0.0-rc2]

# Opal

opal

# Minimalistic ruby implementation - ISO 30170:2012

mruby-1.0.0

mruby-1.1.0

mruby-1.2.0

mruby-1.3.0

mruby-1[.4.0]

mruby[-head]

# Ruby Enterprise Edition

ree-1.8.6

ree[-1.8.7][-2012.02]

# Topaz

topaz

# MagLev

maglev-1.0.0

maglev-1.1[RC1]

maglev[-1.2Alpha4]

maglev-head

# Mac OS X Snow Leopard Or Newer

macruby-0.10

macruby-0.11

macruby[-0.12]

macruby-nightly

macruby-head

# IronRuby

ironruby[-1.1.3]

安装Ruby,从上面查到的信息随便找一个比2.2.2版本要高的就行:

rvm install 2.5

出现如下信息,代表安装成功:

[sidian@VM_0_17_centos ruby_study]$ rvm install 2.5
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/7/x86_64/ruby-2.5.7.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bison, gcc-c++, libtool, patch, readline-devel, sqlite-devel......|
Requirements installation successful.
Installing Ruby from source to: /home/sidian/.rvm/rubies/ruby-2.5.7, this may take a while depending on your cpu(s)...
ruby-2.5.7 - #downloading ruby-2.5.7, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 77 13.1M   77 10.2M    0     0  14986      0  0:15:20  0:11:55  0:03:25 23048

这里的下载比较慢,需要等待比较长时间

验证版本:

成功升级。

注意:

如果使用rvm安装发现下载缓慢,可以考虑删除原来的仓库地址,只保留阿里云镜像。

gem sources --remove https://rubygems.org/

————————————————

版权声明:本文为CSDN博主「唯一昵称真难」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/qq_26440803/java/article/details/82717244