簡體   English   中英

Ruby 無法連接到 ruby​​gems.org

[英]Ruby can't connect to rubygems.org

我已經在 J​​ekyll 站點上工作了一個月沒有問題,但截至本周,每次我嘗試運行bundle install我都會收到錯誤Bundler::HTTPError Could not fetch specs from https://rubygems.org 我使用的是 macOS 10.13,ruby 2.5.1。

這是我的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>'

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/

運行上述腳本,我得到:

/usr/local/Cellar/ruby/2.5.1/bin/ruby (2.5.1-p57)
OpenSSL 1.0.2o  27 Mar 2018: /usr/local/etc/openssl
SSL_CERT_DIR=""
SSL_CERT_FILE=""

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

最后, openssl s_client -connect rubygems.org:443 -tls1顯示:

CONNECTED(00000005)
140735672206280: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
140735672206280: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: 1530836427
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
---

我知道這個問題與我的 SSL 證書有關,但我已經更新了 openssl 和ruby -ropenssl -e "puts OpenSSL::SSL::SSLContext::METHODS.grep(/.+\\d$/).sort"表明我確實有TLSv1_2 ,所以我不知道為什么它不起作用。

幾天來我一直在絞盡腦汁 - 任何幫助將不勝感激! 謝謝!

更新:這不是幾個星期,這個問題不斷消失並再次出現。 前幾天我重新啟動了我的 Mac,一切正常。 今天我遇到了一個全新的錯誤:

$ 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:      success ✅
Ruby net/http connection to rubygems.org: success ✅

Although your Ruby installation and RubyGems can both connect to rubygems.org, Bundler is having trouble. The most likely way to fix this is to upgrade Bundler by running `gem install bundler`. Run this script again after doing that to make sure everything is all set. If you're still having trouble, check out the troubleshooting guide at http://ruby.to/ssl-check-failed 📦
(eval):136: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated

然后我按照說明,運行$ gem install bundler ,然后得到:

ERROR:  Could not find a valid gem 'bundler' (>= 0) in any repository

到底是怎么回事?

在同時使用 rvm 和 brew 運行 $bundle 時,我一直收到“獲取https://rubygems.org/quick/Marshal.4.8/puma-3.11.4.gemspec.rz (執行已過期)時出現網絡錯誤”。

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

Bundler connection to rubygems.org:       failed  ❌  (execution expired)
    RubyGems connection to rubygems.org:      success ✅
    Ruby net/http connection to rubygems.org: success ✅

運行 $bundle --verbose

HTTP GET https://index.rubygems.org/versions
    Net::OpenTimeout: execution expired
    /usr/local/Cellar/ruby/2.5.1/lib/ruby/2.5.0/net/http.rb:937:in `initialize'

這讓我進入了這個頁面:使用 Ruby DNS 解析器來處理 Net::HTTP 中的 DNS 超時,它說在你的代碼中添加 require 'resolv-replace'。 將此添加到 http.rb 解決了我的問題,但我知道這不是最佳解決方案。 我嘗試了此頁面上的所有內容,但是在花了一天的時間后,添加 resolv-replace 為我解決了這個問題。

我正在使用 gem -v 2.7.7 、 ruby​​ -v ruby​​ 2.5.1p57 和 osx 10.9.5。

對於 Mac OS,更改為以下配置有效。

系統偏好設置 > 網絡 > 高級 > TCP/IP > 配置 IPv6:僅本地鏈路

更多信息:https ://rob.co.bb/posts/2018-10-22-yak-shave-gem-install-issue/

我也考慮了很多(我正在運行 Ubuntu VortualBox VM)。 修復它的方法是簡單地禁用 ipv6(從 UI)並重新啟動網絡。

systemctl restart NetworkManager

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM