In the local development environment created by Vagrant, I tried to use rbenv
when inserting ruby
(since it is Vagrant
, basically I'm working with root
).
The installation of rbenv
itself is completed, but when I try to install ruby
with rbenv
, I get the following error.
[root@localhost ~]# rbenv install 2.6.6
Downloading ruby-2.6.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
error: failed to download ruby-2.6.6.tar.bz2
BUILD FAILED (CentOS Linux 7 using ruby-build 20200520-2-gf00582b)
curl
failureI can't seem to download the file. Upon examination, I found that rbenv
uses curl
to download files.
Actually, the environment where I was doing this work was inside the proxy, so I guessed that it was probably due to the network surroundings, so I ran curl
alone and checked its behavior.
[root@localhost ~]# curl https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
curl: (60) Peer's Certificate issuer is not recognized.
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.
curl
also failed. It seems that the cause is either "SSL authentication is not working" or "Proxy is not set up properly". So, first I tried to set the proxy related settings that are likely.
Set the proxy with vi ~ / .curlrc
.
proxy-user="{username}:{password}"
proxy = "http:/{Proxy}:{port number}/"
After setting, I tried running curl
. The error message has changed a little, but it doesn't work (by the way, the specified version is different from the previous one, but I tried switching between this and that version).
[root@localhost ~]# curl -v https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
* Could not resolve proxy: http;Unknown error
* Closing connection 0
curl: (5) Could not resolve proxy: http;Unknown error
curl
alone succeeds due to optional proxy specificationFor curl
, execute the -x
parameter that allows you to set a proxy etc. directly, the -O
that is used for file download, and the parameter -k
that skips certificate errors with SSL connection. The download of curl` alone went well.
curl -k -x http://{username}:{password}@{Proxy}:{port number}/ -v -O https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
...
...
...
0 11.9M 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0{ [data not shown]
100 11.9M 100 11.9M 0 0 1314k 0 0:00:09 0:00:09 --:--:-- 1658k
curl
is successful. However, rbenv
fails.I found that the proxy seemed to be the cause. In order to use this parameter in rbenv
, I next set the same parameter in the alias of curl
.
In vi / etc / bashrc
, set the following at the end.
alias curl="curl -k -x http://{username}:{password}@{Proxy}:{port number}/"
If you reload the settings with source ~ / .bashrc
, omit -x
and -k
and set curl
, curl alone will succeed.
curl -v -O https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.1.tar.bz2
100 11.9M 100 11.9M 0 0 1853k 0 0:00:06 0:00:06 --:--:-- 1899k
However, rbenv
doesn't work.
[root@localhost ~]# rbenv install 2.6.6
Downloading ruby-2.6.6.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.6.tar.bz2
error: failed to download ruby-2.6.6.tar.bz2
BUILD FAILED (CentOS Linux 7 using ruby-build 20200520-2-gf00582b)
RUBY_BUILD_CURL_OPTS
of ruby-build
, rbenv
also succeeded.Think about it, and look at the Github pages for rbenv and ruby-build. If you do, you will notice that there is an environment variable RUBY_BUILD_CURL_OPTS
that allows you to specify options for curl
.
If you execute as follows, it succeeds.
[root@localhost ~]# RUBY_BUILD_CURL_OPTS="-k -x http://{username}:{password}@{Proxy}:{port number}/" rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
Installed ruby-2.7.1 to /root/.rbenv/versions/2.7.1
[root@localhost ~]# rbenv global 2.7.1
[root@localhost ~]# rbenv rehash
[root@localhost ~]# ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
[root@localhost ~]#
Succeeded. I couldn't find a way to use RUBY_BUILD_CURL_OPTS
as far as I searched, so I'll leave it as a memo.
Besides, it seems that you can specify to use ʻaria2cand
wget by using the parameter
RUBY_BUILD_HTTP_CLIENT, so if you can not use
curl itself, you may want to use
RUBY_BUILD_HTTP_CLIENT`. Hmm.
Recommended Posts