Can't run Ruby 2.2.3 with RVM on OSX

2020-03-12 04:56发布

问题:

I've got two MacBooks (one on Mavericks, the other on Yosemite) and the same thing happens on both. After installing Ruby 2.2.3 with RVM, I get the following error:

.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/net/http.rb:923:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (Faraday::SSLError)

I've tried searching for a solution online, but nothing seems to work. Most of the people having this issues are running Windows machines.

$ rvm osx-ssl-certs status all
Certificates for /usr/local/etc/openssl/cert.pem: Up to date.
Certificates for /etc/openssl/cert.pem: Up to date.

Switching back to 2.2.2 works fine. Any thoughts?

回答1:

Downloading http://curl.haxx.se/ca/cacert.pem and adding

export SSL_CERT_FILE=PATH_TO_THe_DOWNLOADED_FILE/cacert.pem

to the .bash_profile/.zshrc partially fixed the issue, because it throws the following error on my system:

Excon::Errors::SocketError: Unable to verify certificate, please set `Excon.defaults[:ssl_ca_path] = path_to_certs`, `ENV['SSL_CERT_DIR'] = path_to_certs`, `Excon.defaults[:ssl_ca_file] = path_to_file`, `ENV['SSL_CERT_FILE'] = path_to_file`, `Excon.defaults[:ssl_verify_callback] = callback` (see OpenSSL::SSL::SSLContext#verify_callback), or `Excon.defaults[:ssl_verify_peer] = false` (less secure).

Setting Excon.defaults[:ssl_verify_peer] to false in a Rails initializer (only on development/test envs) makes it work.

Update: Reinstalling 2.2.3 from source got rid of all my problems.

rvm remove 2.2.3
rvm install 2.2.3 --disable-binary


回答2:

Couldn't help myself otherwise than with brew install openssl on El Capitan. I've tried everything like updating certs using RVM, replacing SSL certs from haxx.se, or reinstalling ruby. Nothing else worked.