Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
604 views
in Technique[技术] by (71.8m points)

debian jessie - gem cannot access rubygems.org

I have a server with Rackspace that I use for a few Ruby sites. When I try bundle install on a new site I get

Retrying download gem from http://rubygems.org/ due to error (2/4): Gem::RemoteFetcher::UnknownHostError timed out (http://rubygems.org/gems/rake-12.3.1.gem)

Or trying gem update --system I get

ERROR:  While executing gem ... (Gem::RemoteFetcher::UnknownHostError)
timed out (http://api.rubygems.org/specs.4.8.gz)

What I have tried:

  • Using curl to download the gem URL in the first error (successful)
  • Change gem source from https://rubygems.org to http://rubygems.org
  • Change the name servers on the slice to use Google's
  • Downloading and updating gem from source (on 2.7.6)
  • Run apt-get update
  • Adding AddTrustExternalCARoot-2048.pem

What I haven't tried:

  • Animal sacrifice
  • Lucky rabbit foot
  • Deleting all files and reinstalling the image

I was finally (just before submitting this) able to get bundle install to work by removing rubygems.org as a source and adding https://gems.ruby-china.org/. Why would gem be unable to access rubygems.org?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

api.rubygems.org is currently experiencing issues with IPv6 setup: this hostname has 4 IPv6 addresses, but responds on neither of them. Neither to ping, nor to TCP connection attempts. When you are running gem, your gem tries IPv6 addresses first and times out on them, not having time to even try IPv4 addresses.

The solution is to lower priority of IPv6 addresses for api.rubygems.org, so that gem will try IPv4 addresses first. In order to do it, put these lines into /etc/gai.conf:


# Debian defaults.
precedence  ::1/128         50
precedence  ::/0            40
precedence  2002::/16       30
precedence  ::/96           20
precedence  ::ffff:0:0/96   10

# Low precedence for api.rubygems.org IPv6 addresses.
precedence  2a04:4e42::0/32  5


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...