安装rails gem时出错

时间:2015-01-07 16:27:43

标签: ruby-on-rails-4 gem

所以我在VPS上安装了ruby 2.2.0,我试图安装rails。唯一的问题是,当我做一个gem安装rails它失败了。我用回溯尝试了它,以下是我得到的:

usera@node3:~$ gem install --backtrace rails
ERROR:  While executing gem ... (SocketError)
    getaddrinfo: Name or service not known
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:791:in `send'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:791:in `send'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:672:in `request'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:528:in `block in fetch_resource'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1096:in `block (3 levels) in resolv'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1094:in `each'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1094:in `block (2 levels) in resolv'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1093:in `each'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1093:in `block in resolv'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1091:in `each'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:1091:in `resolv'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:519:in `fetch_resource'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:509:in `each_resource'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/resolv.rb:490:in `getresource'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/remote_fetcher.rb:92:in `api_endpoint'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/source.rb:46:in `api_uri'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/source.rb:85:in `dependency_resolver_set'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/resolver/best_set.rb:23:in `block in pick_sets'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/source_list.rb:97:in `each'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/source_list.rb:97:in `each_source'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/resolver/best_set.rb:22:in `pick_sets'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/resolver/best_set.rb:28:in `find_all'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/resolver/installer_set.rb:151:in `find_all'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/resolver/installer_set.rb:54:in `add_always_install'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/dependency_installer.rb:463:in `resolve_dependencies'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/commands/install_command.rb:238:in `install_gem'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/commands/install_command.rb:299:in `block in install_gems'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/commands/install_command.rb:295:in `each'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/commands/install_command.rb:295:in `install_gems'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/commands/install_command.rb:202:in `execute'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command.rb:307:in `invoke_with_build_args'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command_manager.rb:168:in `process_args'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command_manager.rb:138:in `run'
        /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/gem_runner.rb:54:in `run'
        /home/usera/.rbenv/versions/2.2.0/bin/gem:21:in `<main>'

我也跑了gem install --backtrace -p rails并获得了以下

usera@node3:~$ gem install --backtrace -p rails
ERROR:  While executing gem ... (OptionParser::InvalidArgument)
    invalid argument: -p rails
    /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/local_remote_options.rb:27:in `block in accept_uri_http'
    /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command.rb:377:in `handle_options'
    /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command.rb:298:in `invoke_with_build_args'
    /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command_manager.rb:168:in `process_args'
    /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/command_manager.rb:138:in `run'
    /home/usera/.rbenv/versions/2.2.0/lib/ruby/2.2.0/rubygems/gem_runner.rb:54:in `run'
    /home/usera/.rbenv/versions/2.2.0/bin/gem:21:in `<main>'

似乎在我的其他VPS上工作正常,所以我有点困惑。

提前致谢!

1 个答案:

答案 0 :(得分:11)

所以我终于弄清楚发生了什么。事实证明,DNS服务器的配置文件在IP地址之后有一个额外的逗号,导致它无法正确解析。我在ubuntu 14.04上,文件在/etc/resolve.conf中。