Rubygems: SSL connect issue to RubyGems - worked through troubleshooting guide

Created on 18 Aug 2018  ·  2Comments  ·  Source: rubygems/rubygems

I'm having a problem. The specific error message is:

Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

I am using rbenv to manage my Ruby installations. I have a working project using Ruby 2.2.0 and there are no issues in this project. I would like to install and use Rails 5 which requires 2.2.2 or later.

I installed Ruby 2.3.0 using rbenv and created a new project directory, setting 2.3.0 as the local version for that directory. I execute gem install bundler or any gem install command and receive the above error. I have followed the steps in this guide.

Here are my environment details for the project folder set to use Ruby 2.3.0:

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.1
  - RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-darwin14]
  - INSTALLATION DIRECTORY: /Users/robinjfisher/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0
  - USER INSTALLATION DIRECTORY: /Users/robinjfisher/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /Users/robinjfisher/.rbenv/versions/2.3.0/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/robinjfisher/.rbenv/versions/2.3.0/bin
  - SPEC CACHE DIRECTORY: /Users/robinjfisher/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/robinjfisher/.rbenv/versions/2.3.0/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-14
  - GEM PATHS:
     - /Users/robinjfisher/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0
     - /Users/robinjfisher/.gem/ruby/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document\\n"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/robinjfisher/.rbenv/versions/2.3.0/bin
     - /Users/robinjfisher/.rbenv/libexec
     - /Users/robinjfisher/.rbenv/plugins/ruby-build/bin
     - /Users/robinjfisher/.rbenv/plugins/rbenv-vars/bin
     - /Users/robinjfisher/.rbenv/shims
     - /Users/robinjfisher/.rbenv/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/openssl/bin
     - /Users/robinjfisher/.rbenv/shims
     - /Users/robinjfisher/.rbenv/bin

$ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
OpenSSL 1.0.2p  14 Aug 2018

$ rbenv --version
rbenv 0.4.0-129-g7e0e85b

I will abide by the code of conduct.

All 2 comments

$ ruby -ropen-uri -e 'eval open("https://git.io/vQhWq").read'

Here's your Ruby and OpenSSL environment:

Ruby:           2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
RubyGems:       2.5.1
Compiled with:  OpenSSL 1.0.2p  14 Aug 2018
Loaded version: OpenSSL 1.0.2p  14 Aug 2018
SSL_CERT_FILE:  /Users/robinjfisher/.rbenv/versions/2.3.0/openssl/ssl/cert.pem
SSL_CERT_DIR:   /Users/robinjfisher/.rbenv/versions/2.3.0/openssl/ssl/certs

With that out of the way, let's see if you can connect to rubygems.org...

Bundler connection to rubygems.org:       failed  ❌  (uninitialized constant Bundler)
RubyGems connection to rubygems.org:      failed  ❌  (certificate verification)
Ruby net/http connection to rubygems.org: failed  ❌

Unfortunately, this Ruby can't connect to rubygems.org. 😡
Your Ruby can't connect to rubygems.org because you are missing the certificate files OpenSSL needs to verify you are connecting to the genuine rubygems.org servers.

OK, after plugging away at this today, I reached a solution. Might not be ideal but worked for me.

$ gem sources -r https://rubygems.org/
$ gem sources -a http://rubygems.org/
$ gem update --system
$ gem sources -a https://rubygems.org/
$ gem sources -r http://rubygems.org/

Basically, running RubyGems update over an insecure link then reinstating the secure URL once everything had updated. Seems to have worked OK.

Was this page helpful?
0 / 5 - 0 ratings