apt update
apt install ruby
不过,安装的是比较老的 ruby 2.3 版本。
所以,还是得用 rvm 来安装最新的 ruby 3.0+
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
如果,上面密钥服务器 hkp://keys.gnupg.net 无法连接,请更换为如下服务器地址:
hkp://pgp.mit.edu
apt install ca-certificates
# 安装稳定版
curl -sSL https://get.rvm.io | bash -s stable
# 安装开发版
curl -sSL https://get.rvm.io | bash
如果出现如下错误:
curl: (60) Issuer certificate is invalid.
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.
需要在调用 cur l时添加 -k 参数:
curl -skSL https://get.rvm.io | bash -s stable
root@ubuntu:/# 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[.10]
[ruby-]2.5[.8]
[ruby-]2.6[.6]
[ruby-]2.7[.2]
[ruby-]3[.0.0]
rvm install ruby-3
确认 ruby 安装无误:
hopy@ubuntu:/# ruby -v
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
打完收工,棒棒哒!