ruby-on-rails – “gem install rails”失败,出现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)

我试图:

>安装其他宝石(devise,activerecord)。我得到相同的错误。
>重新安装RVM
>运行gem update –system
>将静态DNS设置为谷歌的8.8.8.8和8.8.4.4
>将https://production.cf.rubygems.org添加为宝石来源(有关错误,请参阅下文)
>在我之前的12.04中安装14.04。错误仍然存​​在。错误的来源必须在我的电脑之外。

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

>我可以通过浏览器连接到https://rubygems.org/
>我的调制解调器的防火墙完全禁用。
> $ 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

添加直接宝石来源

参考:http://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)

宝石安装导轨的附加调试信息

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现在是调制解调器在进行连接之前尝试联系的有效域名)。

我有同样的问题,并且在resolv.conf上的修改似乎是诀窍,这应该是Linux接受的解决方案。我在运行ubuntu的虚拟机上尝试这个问题时遇到了这个问题,而我的主机(OSX Mavericks)正在传递搜索home.network像调制解调器,所以我想看看能否找到一个可以在主机操作系统级别,因为在我的OSX终端上尝试gem安装rails时发生同样的问题。

如果您进入OSX网络设置,在DNS下,您将在“搜索域”区域下看到home.network行。经过一番搜索,似乎comcast最近从http://hds1.ma.comcast.net更改了这一点。我改变了它,重新启动,并给宝石安装rails另一个镜头,这没有任何问题。

奇怪的问题,但这是一个更好的解决方案,交换调制解调器或更改宝石来源。

http://stackoverflow.com/questions/25583938/gem-install-rails-fails-with-dns-error

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:ruby-on-rails – “gem install rails”失败,出现DNS错误