• 在 Ubuntu 新装系统中安装 ruby 的几点注意


    在这里插入图片描述

    用 apt 管理器安装

    1. 首先,新安装的 Ubuntu 系统需要更新apt仓库:
    apt update
    
    1. 接着可以直接用以下命令安装 ruby:
    apt install ruby
    

    不过,安装的是比较老的 ruby 2.3 版本。

    所以,还是得用 rvm 来安装最新的 ruby 3.0+

    用 rvm 安装

    1. 首先,导入密钥:
    gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
    

    如果,上面密钥服务器 hkp://keys.gnupg.net 无法连接,请更换为如下服务器地址:

    hkp://pgp.mit.edu
    
    1. 安装CA证书:
    apt install ca-certificates
    
    1. 可以选择安装稳定或开发版的rvm:
    # 安装稳定版
    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
    
    1. 安装完 rvm 之后,需要用 source 指令更新一下当前 shell 环境;然后我们可以查询当前所有可用的 ruby 版本:
    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]
    
    1. 最后,我们可以选择安装最新版的 ruby 啦:
    rvm install ruby-3
    

    确认 ruby 安装无误:

    hopy@ubuntu:/# ruby -v
    ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]
    

    打完收工,棒棒哒!😎

  • 相关阅读:
    TensorRT开发环境搭建
    lssvm聚类研究(Matlab代码实现)
    KubeEdge 边缘端架构设计
    2021年Javascript最常见的面试题以及答案
    黑塞矩阵-二阶偏导矩阵
    Linux学习笔记(10)----静态库与共享库
    挑战10个最难回答的Java面试题(附答案)
    Java审计对比工具JaVers使用
    1325. Delete Leaves With a Given Value
    【前端】关于Flow中的联结类型如何使用
  • 原文地址:https://blog.csdn.net/mydo/article/details/126951981