安装 rvm

1
curl -L get.rvm.io | bash -s stable

如果出现一下错误

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 47 0 0:00:04 0:00:04 --:--:-- 47
100 24535 100 24535 0 0 4035 0 0:00:06 0:00:06 --:--:-- 14165
Downloading https://github.com/rvm/rvm/archive/1.29.9.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc
gpg: Signature made Wed 10 Jul 2019 04:31:02 PM CST using RSA key ID 39499BDB
gpg: Can't check signature: No public key
GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.9.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.9/1.29.9.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:

gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

or if it fails:

command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

In case of further problems with validation please refer to https://rvm.io/rvm/security

运行,可能需要翻墙

1
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

再次运行

1
curl -L get.rvm.io | bash -s stable
1
Installing RVM to /usr/local/rvm/

被安装到/usr/local/rvm/,所以rvm真实路径是/usr/local/rvm/bin/rvm

1
/usr/local/rvm/bin/rvm install 2.3.3 

很慢,是国外源需要修改配置

1
2
cd /usr/local/rvm/config/
grep -nR "ruby-lang.org" ./
1
2
./db:78:ruby_url=https://cache.ruby-lang.org/pub/ruby
./db:79:ruby_url_fallback_1=https://ftp.ruby-lang.org/pub/ruby

显示在78行,修改地址为国内源 打开https://github.com/huacnlee/init.d/blob/master/install_rvm其中一句

1
2
3
···
echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db
···

将db中的地址改为https://cache.ruby-china.com/pub/ruby

重新安装

1
/usr/local/rvm/bin/rvm install 2.3.3 --disable-binary