无法在任何存储库中找到有效的gem“rails”(> = 0)

时间:2012-05-25 19:34:30

标签: ruby-on-rails ruby macos gem install

我正在使用新的mac并且刚刚使用rvm安装了ruby 1.9.3。现在我正在尝试安装rails并在这篇文章的标题上得到错误。我将从命令行发布以下所有信息,看看是否有人可以帮助我!

Leonardos-MacBook-Air:~ leo$ gem install rails
WARNING:  Error fetching data: SocketError: getaddrinfo: nodename nor servname provided, or not known (http://rubygems.org/latest_specs.4.8.gz)
ERROR:  Could not find a valid gem 'rails' (>= 0) in any repository
ERROR:  Possible alternatives: rails
Leonardos-MacBook-Air:~ leo$ ping rubygems.org
PING rubygems.org (204.232.149.25): 56 data bytes
64 bytes from 204.232.149.25: icmp_seq=0 ttl=47 time=104.399 ms
64 bytes from 204.232.149.25: icmp_seq=1 ttl=47 time=105.760 ms
^C
--- rubygems.org ping statistics ---
2 packets transmitted, 2 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 104.399/105.079/105.760/0.681 ms
Leonardos-MacBook-Air:~ leo$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-darwin11.4.0]
  - INSTALLATION DIRECTORY: /Users/leo/.rvm/gems/ruby-1.9.3-p194
  - RUBY EXECUTABLE: /Users/leo/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/leo/.rvm/gems/ruby-1.9.3-p194/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-11
  - GEM PATHS:
     - /Users/leo/.rvm/gems/ruby-1.9.3-p194
     - /Users/leo/.rvm/gems/ruby-1.9.3-p194@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
Leonardos-MacBook-Air:~ leo$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
Leonardos-MacBook-Air:~ leo$ 

2 个答案:

答案 0 :(得分:4)

这里的线索是WARNING: Error fetching data: SocketError: getaddrinfo: nodename nor servname provided, or not known (http://rubygems.org/latest_specs.4.8.gz)

这表明目前Rubygems.org存在问题。你的结局几乎肯定没有错。稍等一会再试,应该没问题。我只是尝试使用Mac而且工作正常。

答案 1 :(得分:1)

我已使用gem install的proxy命令选项修复了此问题。它具有以下格式:

$ gem install --http-proxy http://201.187.107.19:8080 rails

注意,IP地址和端口号是指代理。您应该搜索代理列表并使用其中一个代理。

这是包含代理的网站:http://www.cybersyndrome.net/pla5.html

此外,我必须尝试7或8个不同的代理才能成功。不要放弃。

注意,您也可以看到以下错误:

ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: rails requires activesupport (= 3.2.8), actionpack (= 3.2.8), activerecord (= 3.2.8), activeresource (= 3.2.8), actionmailer (= 3.2.8), railties (= 3.2.8), bundler (~> 1.0)

不要放弃并继续列表中的下一个代理。祝你好运。