Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby can't connect to rubygems.org #2342

Closed
1 of 5 tasks
bildungsroman opened this issue Jul 2, 2018 · 12 comments
Closed
1 of 5 tasks

Ruby can't connect to rubygems.org #2342

bildungsroman opened this issue Jul 2, 2018 · 12 comments

Comments

@bildungsroman
Copy link

I'm having a problem or would like to suggest a feature.

My current problem is I can't bundle install any gems as of today.

This issue is related to:

  • Network problems
  • Installing a library
  • Publishing a library
  • The command line gem
  • Other

Here are my current environment details:

$ gem env version
2.7.7

I will abide by the code of conduct.

As of today, I can't install any bundles on my laptop (macOS high sierra). Here is the problem output:

$ ruby -ropen-uri -e 'eval open("https://git.io/vQhWq").read'
Here's your Ruby and OpenSSL environment:

Ruby:           2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17]
RubyGems:       2.7.7
Bundler:        1.16.2
Compiled with:  LibreSSL 2.2.7
Loaded version: LibreSSL 2.2.7
SSL_CERT_FILE:  /private/etc/ssl/cert.pem
SSL_CERT_DIR:   /private/etc/ssl/certs

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

Bundler connection to rubygems.org:       failed  ❌  (execution expired)
RubyGems connection to rubygems.org:      failed  ❌  (timed out (https://rubygems.org))
Ruby net/http connection to rubygems.org: failed  ❌

Unfortunately, this Ruby can't connect to rubygems.org. 😡
Even worse, we're not sure why. 😕

Here's the full error information:
Net::OpenTimeout: execution expired
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880:in `initialize'
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880:in `open'
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880:in `block in connect'
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/timeout.rb:101:in `timeout'
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:878:in `connect'
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
  /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:858:in `start'
  (eval):90:in `<main>'
  -e:1:in `eval'
  -e:1:in `<main>'

You might have more luck using Mislav's SSL doctor.rb script. You can get it here:
https://github.com/mislav/ssl-tools/blob/8b3dec4/doctor.rb
Read more about the script and how to use it in this blog post:
https://mislav.net/2013/07/ruby-openssl/

Running the suggested script, I got:

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby (2.3.3-p222)
LibreSSL 2.2.7: /private/etc/ssl
SSL_CERT_DIR=""
SSL_CERT_FILE=""

HEAD https://status.github.com:443
#<Net::HTTPGatewayTimeOut 504 GATEWAY_TIMEOUT readbody=true>

Any idea how to fix this and why it randomly broke after working just fine last week?

@bildungsroman
Copy link
Author

Here is the output of openssl s_client -connect rubygems.org:443 -tls1 :

CONNECTED(00000005)
140736022356936:error:1409442E:SSL routines:SSL3_READ_BYTES:tlsv1 alert protocol version:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.50.2/libressl/ssl/s3_pkt.c:1133:SSL alert number 70
140736022356936:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:/BuildRoot/Library/Caches/com.apple.xbs/Sources/libressl/libressl-22.50.2/libressl/ssl/s3_pkt.c:522:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 0 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1
    Cipher    : 0000
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: 
    Start Time: 1530566683
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---

@bildungsroman
Copy link
Author

And the output of gem install jekyll-babel --debug, which is what started this whole mess:

NOTE:  Debugging mode prints all exceptions even when rescued
Exception `LoadError' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/resolv.rb:171 - LoadError
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:882 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/timeout.rb:112 - execution expired
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:306 - timed out (https://api.rubygems.org/api/v1/dependencies)
Exception `Errno::EEXIST' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /Users/stackery/.gem/specs/api.rubygems.org%443
Exception `Errno::ENOENT' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:325 - No such file or directory @ rb_file_s_stat - /Users/stackery/.gem/specs/api.rubygems.org%443/prerelease_specs.4.8
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:882 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/timeout.rb:112 - execution expired
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:306 - timed out (https://api.rubygems.org/prerelease_specs.4.8.gz)
Exception `Errno::EEXIST' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /Users/stackery/.gem/specs/api.rubygems.org%443
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:882 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/timeout.rb:112 - execution expired
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:306 - timed out (https://api.rubygems.org/specs.4.8.gz)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/spec_fetcher.rb:269 - timed out (https://api.rubygems.org/specs.4.8.gz)
Exception `Gem::UnsatisfiableDependencyError' at /Library/Ruby/Site/2.3.0/rubygems/resolver/installer_set.rb:72 - Unable to resolve dependency: user requested 'jekyll-babel (>= 0)'
ERROR:  Could not find a valid gem 'jekyll-babel' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - timed out (https://api.rubygems.org/specs.4.8.gz)
Exception `Errno::EEXIST' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /Users/stackery/.gem/specs/api.rubygems.org%443
Exception `Errno::ENOENT' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:325 - No such file or directory @ rb_file_s_stat - /Users/stackery/.gem/specs/api.rubygems.org%443/latest_specs.4.8
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:882 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/timeout.rb:112 - execution expired
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:306 - timed out (https://api.rubygems.org/latest_specs.4.8.gz)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/spec_fetcher.rb:269 - timed out (https://api.rubygems.org/latest_specs.4.8.gz)
Exception `Errno::EEXIST' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253 - File exists @ dir_s_mkdir - /Users/stackery/.gem/specs/api.rubygems.org%443
Exception `Errno::ENOENT' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:325 - No such file or directory @ rb_file_s_stat - /Users/stackery/.gem/specs/api.rubygems.org%443/prerelease_specs.4.8
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:880 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/net/http.rb:882 - execution expired
Exception `Net::OpenTimeout' at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/timeout.rb:112 - execution expired
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/remote_fetcher.rb:306 - timed out (https://api.rubygems.org/prerelease_specs.4.8.gz)
Exception `Gem::RemoteFetcher::UnknownHostError' at /Library/Ruby/Site/2.3.0/rubygems/spec_fetcher.rb:269 - timed out (https://api.rubygems.org/prerelease_specs.4.8.gz)

@indirect
Copy link
Member

indirect commented Jul 3, 2018

The output from your opessl s_client command indicates that your OpenSSL is too old to connect to RubyGems.org. We require TLS v1.2, and the error tlsv1 alert protocol version means that your OpenSSL tried to use v1.0 or v1.1.

I don't know if that's related to your issue connecting from Ruby, since the script says your Ruby is linked against LibreSSL.

Either way, your entire system isn't able to connect to rubygems.org, and that isn't a problem with Ruby or RubyGems. You'll need to update your OS or OpenSSL version or both, and then reinstall Ruby and try again.

@bildungsroman
Copy link
Author

Ok, thank you for your help!

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Jul 3, 2018

@bildungsroman

TLSv1_2 needs to appear in:

ruby -ropenssl -e "puts OpenSSL::SSL::SSLContext::METHODS.grep(/.+\d$/).sort"

@bildungsroman
Copy link
Author

I reinstalled Ruby and Bundler, and it seems to be working now. @MSP-Greg my output is:

-e:1: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
SSLv2
SSLv23
SSLv3
TLSv1
TLSv1_1
TLSv1_2

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Jul 3, 2018

@bildungsroman

I reinstalled Ruby and Bundler

Good idea. Update to Ruby 2.5 also? I believe OpenSSL::SSL::SSLContext::METHODS isn't deprecated until Ruby 2.5 / Ruby OpenSSL 2.1.

@bildungsroman
Copy link
Author

I have now, though it's weird that I was on Ruby 2.3 when I first started having issues.

@bildungsroman
Copy link
Author

bildungsroman commented Jul 3, 2018

Nevermind, it's not working again today despite working yesterday afternoon after the update. @indirect I'm on the newest versions of macOS and Ruby.

Here is the output of ruby -ropen-uri -e 'eval open("https://git.io/vQhWq").read' :

Here's your Ruby and OpenSSL environment:

Ruby:           2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
RubyGems:       2.7.7
Bundler:        1.16.2
Compiled with:  OpenSSL 1.0.2o  27 Mar 2018
Loaded version: OpenSSL 1.0.2o  27 Mar 2018
SSL_CERT_FILE:  /usr/local/etc/openssl/cert.pem
SSL_CERT_DIR:   /usr/local/etc/openssl/certs

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

Bundler connection to rubygems.org:       failed  ❌  (execution expired)
RubyGems connection to rubygems.org:      failed  ❌  (timed out (https://rubygems.org))
Ruby net/http connection to rubygems.org: failed  ❌

Unfortunately, this Ruby can't connect to rubygems.org. 😡
Even worse, we're not sure why. 😕

Here's the full error information:
Net::OpenTimeout: execution expired
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:937:in `initialize'
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:937:in `open'
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:937:in `block in connect'
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/timeout.rb:103:in `timeout'
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:935:in `connect'
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:920:in `do_start'
  /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:915:in `start'
  (eval):90:in `<main>'
  -e:1:in `eval'
  -e:1:in `<main>'

@bildungsroman
Copy link
Author

Update: it turns out while I had the newest ruby and OpenSSL installed via homebrew, bundler was not using it by default.

For other users with the same problem, this solved my issue: https://stackoverflow.com/a/37416716/9245716

@indirect
Copy link
Member

indirect commented Jul 3, 2018

Glad to hear that worked for you!

@dhatGuy
Copy link

dhatGuy commented Aug 18, 2019

I was able able to resolve this issue by closing Kaspersky Anti-Virus completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants