我刚刚按照这里的指南在OSX上安装了Ruby 2.1:
https://github.com/postmodern/chruby/wiki/Ruby
一切似乎运行正常,我已经成功安装了几个 gem。
然而,在使用以下命令安装 rails 时出现问题:
$ sudo gem install rails -V
安装过程中出现错误,安装中途失败,错误信息如下:
ERROR: While executing gem ... (Gem::RemoteFetcher::UnknownHostError) no such name (https://api.rubygems.org/quick/Marshal.4.8/atomic-1.1.4-java.gemspec.rz)
我可以使用curl或者将其粘贴到地址栏来从URL获取文件,因此该文件似乎确实存在。
为什么安装会失败呢?
我没有使用代理,使用
--no-http-proxy
标志也没有任何效果。在出现错误之前,已成功下载了约100个其他文件:
HEAD https://api.rubygems.org/latest_specs.4.8.gz
302 Moved Temporarily
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/latest_specs.4.8.gz
304 Not Modified
GET https://api.rubygems.org/quick/Marshal.4.8/rails-4.0.2.gemspec.rz
302 Moved Temporarily
GET https://aws-eu-cache01.rubygems.org/quick/Marshal.4.8/rails-4.0.2.gemspec.rz
200 OK
HEAD https://api.rubygems.org/specs.4.8.gz
302 Moved Temporarily
HEAD https://s3.amazonaws.com/production.s3.rubygems.org/specs.4.8.gz
304 Not Modified
GET https://api.rubygems.org/quick/Marshal.4.8/railties-4.0.2.gemspec.rz
302 Moved Temporarily
GET https://aws-eu-cache01.rubygems.org/quick/Marshal.4.8/railties-4.0.2.gemspec.rz
...等等