Can't install Ruby rvm on Ubuntu 16.04 due to

2019-03-13 08:04发布

问题:

I'm trying to install Ruby on Ubuntu 16.04. However when I enter to following command to terminal:

$ \curl -sSL https://get.rvm.io | bash -s stable --ruby

I get the following:

Downloading https://github.com/rvm/rvm/archive/1.29.1.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc
gpg: Signature made 19 فبر, 2017 EET 10:02:47 م using RSA key ID ********
gpg: Can't check signature: No public key
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for '/home/tamer/.rvm/archives/rvm-1.29.1.tgz' - 'https://github.com/rvm/rvm/releases/download/1.29.1/1.29.1.tar.gz.asc'! Try to install GPG v2 and then fetch the public key:

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys ****************************************

or if it fails:

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

the key can be compared with:

https://rvm.io/mpapis.asc
https://keybase.io/mpapis

NOTE: GPG version 2.1.17 have a bug which cause failures during fetching keys from remote server. Please downgrade or upgrade to newer version (if available) or use the second method described above.

When I tried any rvm command I got 'command not found'.

I tried requesting https://rvm.io/mpapis.asc through the browser. Then running the following:

$ gpg --import mpapis.asc

but I got the following:

gpg: fatal: can't open `/home/tamer/.gnupg/trustdb.gpg': Permission denied
secmem usage: 1408/1408 bytes in 2/2 blocks of pool 1408/65536

I'm not used to do something that I don't understand, so I stopped their and didn't try sudo.

So how can I install Ruby?

Update

I also tried installing gpg2 using:

$ sudo apt-get install gnupg2 -y

and then I tried

$ gpg2 --keyserver hkp://keys.gnupg.net --recv-keys <key>

and also

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

But still, the same result when I try install rvm with the first command.

n.b. I noticed that I have gpg v1.4.20 and gpg2 v2.1.11

回答1:

I am just posting an update solution for it as I faced the same issue in Ubuntu 18.04 while trying to fetch keys for RVM.

The following method is provided by RVM.

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

If it doesn't work out and you try to install rvm directly, the process will fail and provides three suggestions to receive keys. One of which have a step to receive the keys with gpg2.

Install gpg2 in your system before that.

sudo apt install gnupg2

The command is

gpg2 --recv-keys 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

But this command too will not work. So here's an alternative. Just replace the gpg from the older command to gpg2 which worked for me.

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB


回答2:

After trying many ways. I did succeed to install rails as follows:

$ \curl -sSL https://get.rvm.io | bash
$ source /home/<user>/.rvm/scripts/rvm
$ rvm -v
$ rvm install ruby
$ ruby -v
$ sudo apt-get install rubygems
$ gem update
$ sudo apt-get install ruby-dev zlib1g-dev liblzma-dev build-essential patch
$ rvm gemset list
$ gem install rails
$ rails -v

Where "user" is my username



回答3:

I had the same issue but on Debian and I took an alternate approach. In the error message, it says this: "Try to install GPG v2 and then fetch the public key:" with a gpg2 command after it. I went and installed gpg2 first and ran the command it told me to and it worked for me.

sudo apt-get install gnupg2
sudo apt-get install dirmngr
gpg2 --recv-keys <key>
# <Run curl command to install rvm>


回答4:

In addition to the previous answers, if you are behind a firewall, the following command might not work for you.

gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

In that case, you can use the following command to get the keys -

sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys <<key>> <<key>>