“宝石安装导轨"因 DNS 错误而失败 [英] "gem install rails" fails with DNS error

查看:18
本文介绍了“宝石安装导轨"因 DNS 错误而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ rvm use
Using /home/owner/.rvm/gems/ruby-2.1.2
$ gem install rails
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 80 (http://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/thread_safe-0.3.4.gemspec.rz)
$ gem update --system
...
$ gem -v
2.4.1
$ gem install rails
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 80 (http://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/rails-4.1.5.gemspec.rz)

我已经尝试过:

  1. 安装其他 gems(devise、activerecord).我遇到了同样的错误.
  2. 重新安装 RVM
  3. 运行 gem update --system
  4. 将静态 DNS 设置为 google 的 8.8.8.8 和 8.8.4.4
  5. 添加 https://production.cf.rubygems.org 作为 gem 源(错误见下文)
  6. 在我之前的 12.04 上安装 14.04.错误仍然存​​在.错误的来源必须在我的电脑之外.
  1. Installing other gems (devise, activerecord). I get the same error.
  2. Reinstalling RVM
  3. Running gem update --system
  4. Setting static DNS to google's 8.8.8.8 and 8.8.4.4
  5. Adding https://production.cf.rubygems.org as a gem source (see below for error)
  6. Installing 14.04 over my previous 12.04. Error persists. The source of the error must be outside my computer.

关于我的连接的其他信息:

  1. 我可以通过浏览器连接到 https://rubygems.org/
  2. 我的调制解调器的防火墙已完全禁用.
  3. $ curl -v --head https://rubygems.org 输出:http://pastebin.com/ca6DAvaU

我的/etc/resolv.conf

$ cat /etc/resolv.co
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 75.75.75.75
search home.network

添加直接gem源

参考:https://stackoverflow.com/a/19299266/3993020

owner@owner-Z87X-UD3H:~$ gem sources --add https://production.cf.rubygems.org
Error fetching https://production.cf.rubygems.org:
    Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 (https://your-dns-needs-immediate-attention.network/specs.4.8.gz)

gem install rails 的附加调试信息

Additional debug information for gem install rails

owner@owner-Z87X-UD3H:~$ gem install rails --debug -V
NOTE:  Debugging mode prints all exceptions even when rescued
Exception `LoadError' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/resolv.rb:169 - LoadError
HEAD https://api.rubygems.org/api/v1/dependencies
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block
200 OK
GET https://api.rubygems.org/api/v1/dependencies?gems=rails
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block
Exception `OpenSSL::SSL::SSLErrorWaitReadable' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/openssl/buffering.rb:182 - read would block
200 OK
Exception `Resolv::DNS::Config::NXDomain' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/resolv.rb:547 - _rubygems._tcp.api.rubygems.org
Exception `Errno::ECONNREFUSED' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/net/http.rb:879 - Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443
Exception `Gem::RemoteFetcher::FetchError' at /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:286 - Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 (https://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/rails-4.1.5.gemspec.rz)
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    Errno::ECONNREFUSED: Connection refused - connect(2) for "your-dns-needs-immediate-attention.network" port 443 (https://your-dns-needs-immediate-attention.network/quick/Marshal.4.8/rails-4.1.5.gemspec.rz)
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:286:in `rescue in fetch_path'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/remote_fetcher.rb:259:in `fetch_path'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/source.rb:146:in `fetch_spec'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/resolver/api_specification.rb:76:in `spec'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/resolver/installer_set.rb:77:in `add_always_install'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/dependency_installer.rb:461:in `resolve_dependencies'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:238:in `install_gem'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:299:in `block in install_gems'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:295:in `each'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:295:in `install_gems'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/commands/install_command.rb:202:in `execute'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/command.rb:307:in `invoke_with_build_args'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:168:in `process_args'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/command_manager.rb:138:in `run'
    /home/owner/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:54:in `run'
    /home/owner/.rvm/rubies/ruby-2.1.2/bin/gem:21:in `<main>'

推荐答案

就像 blasio 指出的那样.似乎 Xfinity 调制解调器正在将搜索域设置为 home.network 并且由于他提到的原因,这将事情搞砸了(本质上,home.network 现在是调制解调器所在的有效域名)在建立连接之前尝试联系).

Like blasio pointed out. It seems like the Xfinity modems are setting up the search domain to home.network and this is messing things up for the reasons he mentioned (essentially, home.network is now a valid domain name that the modems are trying to contact before making a connection).

我遇到了同样的问题,对 resolv.conf 的修改似乎可以解决问题,这应该是 linux 环境可接受的解决方案.我在运行 ubuntu 的虚拟机上尝试这个时遇到了这个问题,我的主机(OSX Mavericks)像调制解调器一样传递 search home.network,所以我想看看我是否能找到一个可以在主机操作系统级别完成的解决方案,因为当我在我的 OSX 终端上尝试 gem install rails 时发生了同样的问题.

I had the same problem and the modification on resolv.conf seem to do the trick, and that should probably be an accepted solution for linux environments. I had this problem while attempting this on a virtual machine running ubuntu, and my host(OSX Mavericks) was passing down the search home.network like the modem is, so I wanted to see if I could find a solution that could be done at the host OS level because the same problem happened when I attempted gem install rails on my OSX terminal.

如果您转到 OSX 网络设置,在 DNS 下您将看到搜索域区域下的 home.network 行.经过一番谷歌搜索后,comcast 最近似乎将其从 http://hds1.ma.comcast.net' 更改了.我把它改回来,重新启动并给 gem install rails 另一个镜头,它没有问题.

If you go to the OSX network settings, under DNS you'll see the home.network line under the Search Domains area. After some googling it seems that comcast recently changed this from http://hds1.ma.comcast.net'. I changed it back, restarted and gave gem install rails another shot, which worked with no problem.

奇怪的问题,但这是交换调制解调器或更改 gem 源的更好解决方案.

Strange issue but this is a better solution that swapping modems or changing gem sources.

这篇关于“宝石安装导轨"因 DNS 错误而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆