倩 2020-04-22
1. 切换源
$ gem sources -l $ gem sources --remove https://rubygems.org/ $ gem sources -a https://ruby.taobao.org/
2. 测试是否成功
gem sources –l
3.开始安装 rvm
curl -L https://get.rvm.io | bash -s stable source ~/.rvm/scripts/rvm rvm -v 查看rvm是否安装成功
4.安装成功
rvm 1.29.0 (latest) by Wayne E. Seguin <>, Michal Papis <> [https://rvm.io/]
5.升级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[.8] [ruby-]2.4[.5] [ruby-]2.5[.3] [ruby-]2.6[.0]
6. 修改ruby源加快安装速度
echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > /usr/local/rvm/user/db
7.安装 ruby -2.6.6
[ local]# rvm install ruby-2.6 Searching for binary rubies, this might take some time. No binary rubies available for: centos/7/x86_64/ruby-2.6.6. Continuing with compilation. Please read ‘rvm help mount‘ to get more information on binary rubies. Checking requirements for centos. Requirements installation successful. Installing Ruby from source to: /usr/local/rvm/rubies/ruby-2.6.6, this may take a while depending on your cpu(s)... ruby-2.6.6 - #downloading ruby-2.6.6, this may take a while depending on your connection... ruby-2.6.6 - #extracting ruby-2.6.6 to /usr/local/rvm/src/ruby-2.6.6..... ruby-2.6.6 - #configuring...................................................................... ruby-2.6.6 - #post-configuration.. ruby-2.6.6 - #compiling................................................................................................ ruby-2.6.6 - #installing................................ ruby-2.6.6 - #making binaries executable.. ruby-2.6.6 - #downloading rubygems-3.0.8 ** Resuming transfer from byte position 368640 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 507k 100 507k 0 0 468 0 0:18:29 0:18:28 0:00:01 1128 No checksum for downloaded archive, recording checksum in user configuration. ruby-2.6.6 - #extracting rubygems-3.0.8..... ruby-2.6.6 - #removing old rubygems........ ruby-2.6.6 - #installing rubygems-3.0.8................................................................ ruby-2.6.6 - #gemset created /usr/local/rvm/gems/ ruby-2.6.6 - #importing gemset /usr/local/rvm/gemsets/global.gems.................................there was an error installing gem rubygems-bundler ............................... ruby-2.6.6 - #generating global wrappers....... ruby-2.6.6 - #gemset created /usr/local/rvm/gems/ruby-2.6.6 ruby-2.6.6 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list ruby-2.6.6 - #generating default wrappers....... ruby-2.6.6 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake). Install of ruby-2.6.6 - #complete Ruby was built without documentation, to build it run: rvm docs generate-ri
8.查看已经安装的ruby
[ local]# rvm list =* ruby-2.6.6 [ x86_64 ] # => - current # =* - current && default # * - default
9. 切换 ruby-2.6.6
[ local]# rvm use ruby-2.6.6 Using /usr/local/rvm/gems/ruby-2.6.6
10.设置默认ruby版本
[ local]# rvm use ruby-2.6.6 --default Using /usr/local/rvm/gems/ruby-2.6.6