Timeout when installing ruby gems

情到浓时终转凉″ 提交于 2021-02-18 11:22:13

问题


I'm trying to install the bundler gem using $ gem install bundler. When I execute the command, I receive the following response:

ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
    Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Operation   timed out - connect(2) (https://api.rubygems.org/latest_specs.4.8.gz)
ERROR:  Possible alternatives: bundler

In an effort to make sure I wasn't going crazy, I tried installing nokogiri:

ERROR:  Could not find a valid gem 'nokogiri' (>= 0), here is why:
  Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Operation timed out - connect(2) (https://api.rubygems.org/latest_specs.4.8.gz)
ERROR:  Possible alternatives: nokogiri

And a2z:

ERROR:  Could not find a valid gem 'a2z' (>= 0), here is why:
  Unable to download data from https://rubygems.org/ - Errno::ETIMEDOUT: Operation timed out - connect(2) (https://api.rubygems.org/quick/Marshal.4.8/a2z-0.1.3.gemspec.rz)

If anyone has experience this issue before and can help me out it would be greatly appreciated.

If it helps, I'm running MacOS Mavericks and have gem version 2.2.2.


回答1:


In your Gemfile set your

source 'http://production.s3.rubygems.org'

This may not be an official answer, but it worked for me after three frustrating days trying to access rubygems.org.




回答2:


Too Late but i resolve this issue disabling the IPv6 connections in my system OS. It forces the OS just use the IPv4 and then it works.




回答3:


i had the same issue which i solved by disabling my VPN. try looking at proxies, VPNs, and other networking issues.




回答4:


api.rubygems.org is having issues with IPV6 host address. I faced the same issue after I setup the ubuntu server in vbox. We need to configure it to use our host's IPV4 first and then try IPV6.

So we can change the priority by adding this line ti /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

And it worked like a charm!




回答5:


just add --source http://rubygems.org to your installs. The issue most likely is with your internet connection.




回答6:


For people using Windows, the following worked for me on Windows 10. See also my reply on the ruby gems issues list.

  1. Go to Control Panel > Network and Internet > Network connections
  2. Select the network connection you're currently using
  3. Right click on it and choose Properties
  4. Remove check mark for Internet Protocol version 6 (TCP/IPv6)
  5. Click OK
  6. Run your gem command again



回答7:


In my case helped the following:

sudo gem update --system



回答8:


dig api.rubygems.org +short

Adding below line to /etc/hosts worked for me. 151.101.192.70 rubygems.org




回答9:


I ran into the same issue. Try running:

bundle pristine



回答10:


  1. Disable ipv6
  2. sudo gem update --system
  3. gem install bundler



回答11:


  1. ping rubygems.org and get the IP address.
  2. Edit your /etc/hosts file and add the line: <IPADD> rubygems.org.
  3. gem update --system.


来源:https://stackoverflow.com/questions/23659119/timeout-when-installing-ruby-gems

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!