rvm安装ruby,rails及安装过程报错443解决方式

基于ubuntu20.04.3安装rvm。命令如下:

sudo apt-get install gnupg gnupg2#添加相关依赖
sudo apt-get install curl#添加相关依赖

第一步- 安装 RVM

$ gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
$ \curl -sSL https://get.rvm.io | bash -s stable#安装rvm
niufei@niufei-Virtual-Machine:~/Desktop$ \curl -sSL https://get.rvm.io | bash -s stable
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused

执行此步骤报错443。

查询raw.githubusercontent.com的ip写入hosts文件之后。(网上有IP可直接使用)。
sudo gedit /etc/hosts

199.232.28.133 raw.githubusercontent.com

添加完ip 域名之后,保存再执行安装rvm命令即可。期间可能需要安装如下依赖:

curl -sSL https://rvm.io/mpapis.asc | gpg2 –import#添加依赖
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 –import#添加依赖

部分执行信息如下:

niufei@niufei-Virtual-Machine:~/Desktop$ sudo gedit /etc/hosts

(gedit:7395): Tepl-WARNING **: 15:01:42.349: GVfs metadata is not supported. Fallback to TeplMetadataManager. Either GVfs is not correctly installed or GVfs metadata are not supported on this platform. In the latter case, you should configure Tepl with --disable-gvfs-metadata.



niufei@niufei-Virtual-Machine:~/Desktop$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made 2021年01月16日 星期六 02时46分22秒 CST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Can't check signature: No public key
GPG signature verification failed for '/home/niufei/.rvm/archives/rvm-1.29.12.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.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



niufei@niufei-Virtual-Machine:~/Desktop$ curl -sSL https://rvm.io/mpapis.asc | gpg2 --import
gpg: key 3804BB82D39DC0E3: 47 signatures not checked due to missing keys
gpg: key 3804BB82D39DC0E3: "Michal Papis (RVM signing) <mpapis@gmail.com>" 47 new signatures
gpg: Total number processed: 1
gpg:         new signatures: 47
gpg: no ultimately trusted keys found



niufei@niufei-Virtual-Machine:~/Desktop$ curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import
gpg: key 105BD0E739499BDB: public key "Piotr Kuczynski <piotr.kuczynski@gmail.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1



niufei@niufei-Virtual-Machine:~/Desktop$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
curl: (28) Connection timed out after 30001 milliseconds
curl: (28) Connection timed out after 30002 milliseconds
curl: (28) Connection timed out after 30000 milliseconds
curl: (28) Connection timed out after 30002 milliseconds

Could not download 'https://github.com/rvm/rvm/archive/1.29.12.tar.gz'.
  curl returned status '28'.

Downloading https://bitbucket.org/mpapis/rvm/get/1.29.12.tar.gz
Downloading https://bitbucket.org/mpapis/rvm/downloads/1.29.12.tar.gz.asc
gpg: Signature made 2021年01月16日 星期六 02时46分26秒 CST
gpg:                using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <piotr.kuczynski@gmail.com>" [unknown]
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 '/home/niufei/.rvm/archives/rvm-1.29.12.tgz'
Installing RVM to /home/niufei/.rvm/
    Adding rvm PATH line to /home/niufei/.profile /home/niufei/.mkshrc /home/niufei/.bashrc /home/niufei/.zshrc.
    Adding rvm loading line to /home/niufei/.profile /home/niufei/.bash_profile /home/niufei/.zlogin.
Installation of RVM in /home/niufei/.rvm/ is almost complete:

  * To start using RVM you need to run `source /home/niufei/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.

👉  Donate: https://opencollective.com/rvm/donate

期间可能会问你 sudo 管理员密码,以及自动安装依赖包,等待一段时间后就可以成功安装好 RVM。

然后,载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)

$ source ~/.rvm/scripts/rvm

修改 RVM 下载 Ruby 的源,到 Ruby China 的镜像:

$ echo "ruby_url=https://cache.ruby-china.com/pub/ruby" > ~/.rvm/user/db

检查一下是否安装正确

$ rvm -v
rvm 1.22.17 (stable) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

第二步- 用 RVM 安装 Ruby 环境

$ rvm requirements
$ rvm install 2.3.0#ruby版本根据需要安装

同样继续等待漫长的下载,编译过程,完成以后,Ruby, Ruby Gems 就安装好了。

第三步- 设置 Ruby 版本
RVM 装好以后,需要执行下面的命令将指定版本的 Ruby 设置为系统默认版本

$ rvm use 2.3.0 --default

同样,也可以用其他版本号,前提是你有用 rvm install 安装过那个版本

这个时候你可以测试是否正确

$ ruby -v
ruby 2.3.0 ...

$ gem -v
2.1.6

$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

安装 Bundler

$ gem install bundler

第四步- 安装 Rails 环境
上面 3 个步过后,Ruby 环境就安装好了,接下来安装 Rails

$ gem install rails#可加版本号亦可不加

然后测试安装是否正确

$ rails -v
Rails 4.2.5

注:新建rails应用记得安装git。

$ sudo apt-get install git

然后开始你的 Ruby,Rails 之旅吧。 欢迎来到 Ruby 的世界!

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值