参考:

https://blog.csdn.net/qq_35641923/article/details/86493822

https://www.runoob.com/ruby/ruby-installation-unix.html

https://www.jianshu.com/p/1fbbc3f5694a

rvm可以用rbenv代替

报错1:需要添加本地域名hosts解析

[root@centos7 ~]# curl -L https://get.rvm.io | bash -s stable
curl: (7) Failed connect to raw.githubusercontent.com:443; Connection refused #报错
[root@centos7 ~]# curl -L https://get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 103 0 0:00:01 0:00:01 --:--:-- 103
curl: (7) Failed connect to raw.githubusercontent.com:443; Connection refused

解决方法

vim /etc/hosts

加入下面的配置

199.232.28.133 raw.githubusercontent.com

参考下面的连接解决

https://www.jianshu.com/p/c2e829027b0a

报错2 没有公钥

gpg: Can't check signature: 没有公钥
GPG signature verification failed for '/usr/local/rvm/archives/rvm-1.29.11.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.11/1.29.11.tar.gz.asc'! Try to install GPG v2 and then fetch the public key: gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB or if it fails: command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import - In case of further problems with validation please refer to https://rvm.io/rvm/security

解决方法:

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

或者

gpg --keyserver keyserver.ubuntu.com --recv-key 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

报错3:如果提示

gpg: failed to start the dirmngr '/usr/bin/dirmngr': 没有那个文件或目录

这是缺少dirmngr命令,直接apt装一下就行

$ sudo apt install -y dirmngr

再执行下面的curl操作成功了,呵呵

[root@centos7 ~]# curl -L get.rvm.io | bash -s stable
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 194 100 194 0 0 329 0 --:--:-- --:--:-- --:--:-- 329
100 24535 100 24535 0 0 4868 0 0:00:05 0:00:05 --:--:-- 7904
Downloading https://github.com/rvm/rvm/archive/1.29.10.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.10/1.29.10.tar.gz.asc
gpg: Signature made Thu 26 Mar 2020 05:58:42 AM CST using RSA key ID 39499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/usr/local/rvm/archives/rvm-1.29.10.tgz'
Creating group 'rvm'
Installing RVM to /usr/local/rvm/
Installation of RVM in /usr/local/rvm/ is almost complete: * First you need to add all users that will be using rvm to 'rvm' group,
and logout - login again, anyone using rvm will be operating with `umask u=rwx,g=rwx,o=rx`. * To start using RVM you need to run `source /etc/profile.d/rvm.sh`
in all your open shell windows, in rare cases you need to reopen all shell windows.
* Please do NOT forget to add your users to the rvm group.
The installer no longer auto-adds root or users to the rvm group. Admins must do this.
Also, please note that group memberships are ONLY evaluated at login time.
This means that users must log out then back in before group membership takes effect!
Thanks for installing RVM
Please consider donating to our open collective to help us maintain RVM. Donate: https://opencollective.com/rvm/donate
[root@centos7 ~]# source /etc/profile.d/rvm.sh
[root@centos7 ~]# rvm reload
[root@centos7 ~]# rvm -v
rvm 1.29.10 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]

到此rvm安装成功

安装依赖

rvm安装完毕之后,就是ruby的下载安装了

但是在此之前需要安装一下ruby的依赖包,诸如openssl之类的,否则以后会出现各种问题,重新安装也是大麻烦

rvm requirements

输入一下命令检查安装情况

rvm requirements run

将显示:

Checking requirements for centos.

Requirements installation successful.

列出已知的 ruby 版本:

$ rvm list known

最后便可安装ruby了,当然版本可以任选,反正我选2.3.8

rvm install 2.3.8

或者

rvm install 3.0.0

报错例子一:

haima@haima-virtual-machine:~/Desktop$ rvm install 2.3.8
Searching for binary rubies, this might take some time.
No binary rubies available for: ubuntu/20.04/x86_64/ruby-2.3.8.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for ubuntu.
Removing undesired packages: libssl-dev....
Installing requirements for ubuntu.
Updating system....
Installing required packages: gawk, libffi-dev, libgdbm-dev, libncurses5-dev, libsqlite3-dev, libtool, sqlite3, libgmp-dev, libreadline-dev, libssl1.0-dev....
Error running 'requirements_debian_libs_install gawk libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool sqlite3 libgmp-dev libreadline-dev libssl1.0-dev',
please read /home/haima/.rvm/log/1638863120_ruby-2.3.8/package_install_gawk_libffi-dev_libgdbm-dev_libncurses5-dev_libsqlite3-dev_libtool_sqlite3_libgmp-dev_libreadline-dev_libssl1.0-dev.log
Requirements installation failed with status: 100.

解决方法:

参考文章:

ubuntu 20.04使用rvm安装ruby2.3.1报错Error running requirements_debian_libs_install libssl1.0-dev

https://blog.csdn.net/qq_41988167/article/details/106202868

sudo vim /etc/apt/sources.list在/etc/apt/sources.list 中
添加下载源 deb http://security.ubuntu.com/ubuntu bionic-security main保存退出。
sudo apt update。
apt-cache policy libssl1.0-dev
rvm get stable
rvm install ruby-2.3.8

报错例子二:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

haima@haima-virtual-machine:~/Desktop$ rvm use 2.3.8 --default

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example. haima@haima-virtual-machine:~/Desktop$ source ~/.rvm/scripts/rvm
haima@haima-virtual-machine:~/Desktop$ rvm use 2.3.8 --default
Using /home/haima/.rvm/gems/ruby-2.3.8
haima@haima-virtual-machine:~/Desktop$ rvm list
=* ruby-2.3.8 [ x86_64 ]
ruby-2.7.0 [ x86_64 ] # => - current
# =* - current && default
# * - default

检查安装情况

显示如下信息则 安装完成:下面显示本人已经成功安装了两个版本的ruby,并且当前默认使用的是3.0版本 。呵呵

root@haima-PC:/home/haima/Desktop# rvm list
* ruby-2.3.8 [ x86_64 ]
=> ruby-3.0.0 [ x86_64 ] # => - current
# =* - current && default
# * - default

切换默认运行的ruby版本

rvm use 2.3.8 --default

use了某个版本之后,可以使用 which ruby 命令查看当前的ruby命令信息。

如果报下面的错误:

rvm is not a function的解决方法

haima@haima-PC:/usr/local$ rvm use 2.3.8 --default

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.

编辑~/.bashrc

haima@haima-PC:/usr/local$ vim ~/.bashrc

加入下面的代码

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

再执行

haima@haima-PC:/usr/local$ rvm use 2.3.8 --default
Using /home/haima/.rvm/gems/ruby-2.3.8
haima@haima-PC:/usr/local$ rvm -v
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
haima@haima-PC:/usr/local$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-linux]

请参考

https://blog.csdn.net/dazhi_100/article/details/38845689

删除一个已安装的版本:

$ rvm remove 2.3.8

gemset 的使用

列出当前 Ruby 的 gemset

root@haima-PC:/home/haima/Desktop# rvm gemset list

gemsets for ruby-3.0.0 (found in /home/haima/.rvm/gems/ruby-3.0.0)
=> (default)
global

进入ruby控制台

irb

更多参考:

https://blog.csdn.net/u010744827/article/details/84269612

https://ruby-china.org/wiki/rvm-guide

http://www.zzvips.com/article/62805.html

01. Linux 如何安装rvm和ruby的更多相关文章

  1. centos 6.x安装rvm 配置 Ruby开发环境

    rvm是ruby的版本管理工具  还可对ruby进行 安装 卸载 等 1.安装 curl #  sudo yum install  curl #  curl -L  get.rvm.io | bash ...

  2. macosx zsh下安装rvm和ruby

    1)curl -L get.rvm.io | bash -s stable 2)把下面一行加到~/.zshrc中: [[ -s "$HOME/.rvm/scripts/rvm" ] ...

  3. centos 6.5安装rvm 配置 Ruby开发环境

    我是用ruby写测试脚本用  安装rvm也是费了好大劲  英文不易看懂 ,是个硬伤! rvm是ruby的版本管理工具  还可对ruby进行 安装 卸载 等 1.安装 curl #  sudo yum ...

  4. 01 linux上安装 nginx

    一:linux上安装 nginx 下载nginx:wget http://nginx.org/download/nginx-1.6.2.tar.gz 解压:tar zxvf nginx-1.6.2.t ...

  5. ActiveMQ基础01——Linux下载安装ActiveMQ

    1.下载 下载地址:http://activemq.apache.org/ 点击按钮 下载Linux下最新版安装包,点击即可下载 2.安装ActiveMQ 将之前下载的安装包上传到linux当中,一般 ...

  6. Linux下安装jekyll

    折腾了大半天,终于搞定了,这可得记下来了. 我的Linux版本:CentOS 6.5 主要的安装顺序还是官网上的说明:http://jekyllrb.com/docs/installation/,所以 ...

  7. linux下安装ruby版本管理器RVM

    这里以ubuntu为例. 直接以如下命令行安装可能会不成功,因为rvm.io站点有时会被墙: curl -sSL https://get.rvm.io | bash -s stable #或者 cur ...

  8. iOS工具】rvm、Ruby环境和CocoaPods安装使用及相关报错问题解决

    〇.前言 <p>在iOS开发中 CocoaPods作为库依赖管理工具就是一把利器. 有了 CocoaPods则无需再通过拖 第三方库及第三方库所依赖的 framework静态库到项目中等麻 ...

  9. [Ruby on Rails系列]1、开发环境准备:Vmware和Linux的安装

    Ruby on Rails是一个采用Ruby语言的遵循MVC模式的Web开发框架.使用RoR会得到更加快速爽快的Web开发体验.相比于Java EE,该框架使Web开发的速度和效率变得更加轻快和敏捷. ...

  10. 使用rvm安装与切换Ruby

    列出已知的 Ruby 版本 rvm list known安装一个 Ruby 版本 rvm install 2.3.1 --disable-binary这里安装了最新的 2.2.0, rvm list ...

随机推荐

  1. Windows系统使用ODBC驱动访问KingaseES数据库及常见问题解决

    Windows系统使用KingbaseES ODBC驱动访问KingaseES数据库及常见问题解决. 一.获取KingbaseES数据库ODBC驱动: 在官网下载KingbaseES数据库安装包,选择 ...

  2. 记一次 .NET某管理局检测系统 内存暴涨分析

    一:背景 1. 讲故事 前些天有位朋友微信找到我,说他们的WPF程序有内存泄漏的情况,让我帮忙看下怎么回事?并且dump也抓到了,网上关于程序内存泄漏,内存暴涨的文章不计其数,看样子这个dump不是很 ...

  3. WPF入门-导航页

    本文适合有winform或web前端基础,且有C#开发基础的同学学习. 本文介绍的开发模式属于MVVM,即Model-View-ViewModel .这种开发模式上手简单,开发迅速. wpf入门第一篇 ...

  4. 【FAQ】推送服务常见问题及解答

    目录 1.报错6003解决方案. 2.推送成功收不到消息. 3.Gettoken返回0,无法进入onToken函数,无法收到广播. 4.如何在华为开放平台查看消息属性,推送的时候带了importanc ...

  5. Discovery直播 | 移动应用“通行证”——钥匙环,解锁管家式安全出行服务

    用户在登录环节的直接诉求是:别让我等.别让我想.别让我烦.而帐号输入.繁琐验证,以及由此带来的安全风险,总会让很多人望而却步. 如何在简化登录流程的同时保障登录凭证安全?如何帮助用户一键免密登录同一开 ...

  6. MFC程序隐藏托盘+右键关闭菜单

    背景介绍: 我的程序是启动后,默认就隐藏到托盘中,等待http请求后,显示界面.所以最小化到托盘的代码,我是写在初始化里面.     正文: 一.自定义消息 WM_SHOWTASK #define W ...

  7. Copy 进阶用法

    Copy 进阶用法 本文出处:https://www.modb.pro/db/239809 copy 是最基础的导入导出命令,那么它有什么其他用法可以帮助我们更好地进行导入导出的工作呢? 关于导入方式 ...

  8. Mysql之innodb架构

    Innodb存储引擎的架构 内存结构 Bufer Pool 缓冲池是主内存中的一个区域,里面可以缓存磁盘上经常操作的真实数据,在执行增删改查操作时,先操作缓冲池中的数据(若缓冲池没有数据,则从磁盘加载 ...

  9. Avalonia 中的样式和控件主题

    在 Avalonia 中,样式是定义控件外观的一种方式,而控件主题则是一组样式和资源,用于定义应用程序的整体外观和感觉.本文将深入探讨这些概念,并提供示例代码以帮助您更好地理解它们. 样式是什么? 样 ...

  10. VScode 使用emmet

    背景 在很多的编辑场合,很多时候回出现很多逻辑性的问题.可能觉得html是一门没有逻辑的语言,实际上,它是有一定的思想编辑的.后来出现了emmet,这个不仅仅是一种快捷方式,同时也是一种思考方式. 解 ...