步骤1 — 安装RVM(Ruby Version Manager)
安装ruby的版本管理工具
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ curl -sSL https://get.rvm.io | bash -s stable
载入RVM环境
$ source /home/.rvm/scripts/rvm
修改源为Ruby China镜像
echo "ruby_url=https://cache.ruby-china.org/pub/ruby" > ~/.rvm/user/db
检查是否安装成功
$ rvm -v
rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
步骤2 — 用RVM安装指定版本Ruby环境
$ rvm requirements
$ rvm install 2.5.0
查看rvm list是否正确安装Ruby
$ rvm list
rvm rubies
* ruby-2.4.0 [ x86_64 ]
=> ruby-2.5.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
步骤3 — 设置Ruby版本
设置系统当前默认Ruby版本
$ rvm use 2.5.0 --default
检查环境是否配置正确
$ ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
$ gem -v
2.7.3
设置gem源为Ruby China镜像
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
安装Bundler
$ gem install bundler
检查是否安装成功
$ bundler -v
Bundler version 1.16.2
步骤4 — 安装Rails
最后安装Rails
$ gem install rails
检查是否安装成功
$ rails -v
Rails 5.2.0
安装RVM时可能会遇到的问题
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ curl -sSL https://get.rvm.io | bash -s stable
or
$ curl -L https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
$ chown -R $(whoami) ~/.gnupg/
Problem description
crystal@crystal:~$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: Signature made Mon Sep 11 04:59:21 2017 CST using RSA key ID BF04FF17
gpg: Fatal: can't open '/home/crystal/.gnupg/trustdb.gpg': Permission denied
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).
GPG signature verification failed for '/home/crystal/.rvm/archives/rvm-1.29.3.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
or if it fails:
command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
the key can be compared with:
https://rvm.io/mpapis.asc
https://keybase.io/mpapis
NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.
$ curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
$ source /home/crystal/.rvm/scripts/rvm
现存问题
通过RVM安装ruby 2.3.0时候遇到的问题
Error running '__rvm_make -j4',
please read /home/wayne/.rvm/log/1529486866_ruby-2.3.0/make.log
There has been an error while running make. Halting the installation.
网友评论