Gem 求助,安装问题 (Gem::DependencyError)

wtl · 2011年12月25日 · 最后由 WRLin 回复于 2015年02月12日 · 18213 次阅读

gem install rails

ERROR:  While executing gem ... (Gem::DependencyError)
    Unable to resolve dependencies: railties requires rdoc (~> 3.4); mail requires mime-types (~> 1.16), treetop (~> 1.4.8); sprockets requires hike (~> 1.2), tilt (!= 1.3.0, ~> 1.1)

rvm info

ruby-1.9.3-p0@walalu:

  system:
    uname:       "Darwin mac.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64"
    bash:        "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
    zsh:         "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"

  rvm:
    version:      "rvm 1.10.0 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p0"
    date:         "2011-10-30"
    platform:     "x86_64-darwin11.2.0"
    patchlevel:   "2011-10-30 revision 33570"
    full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]"

  homes:
    gem:          "/Users/mac/.rvm/gems/ruby-1.9.3-p0@walalu"
    ruby:         "/Users/mac/.rvm/rubies/ruby-1.9.3-p0"

  binaries:
    ruby:         "/Users/mac/.rvm/rubies/ruby-1.9.3-p0/bin/ruby"
    irb:          "/Users/mac/.rvm/rubies/ruby-1.9.3-p0/bin/irb"
    gem:          "/Users/mac/.rvm/rubies/ruby-1.9.3-p0/bin/gem"
    rake:         "/Users/mac/.rvm/gems/ruby-1.9.3-p0@global/bin/rake"

  environment:
    PATH:         "/Users/mac/bin:/Users/mac/.rvm/gems/ruby-1.9.3-p0@walalu/bin:/Users/mac/.rvm/gems/ruby-1.9.3-p0@global/bin:/Users/mac/.rvm/rubies/ruby-1.9.3-p0/bin:/Users/mac/.rvm/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/local/Trolltech/Qt-4.7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin"
    GEM_HOME:     "/Users/mac/.rvm/gems/ruby-1.9.3-p0@walalu"
    GEM_PATH:     "/Users/mac/.rvm/gems/ruby-1.9.3-p0@walalu:/Users/mac/.rvm/gems/ruby-1.9.3-p0@global"
    MY_RUBY_HOME: "/Users/mac/.rvm/rubies/ruby-1.9.3-p0"
    IRBRC:        "/Users/mac/.rvm/rubies/ruby-1.9.3-p0/.irbrc"
    RUBYOPT:      ""
    gemset:       "walalu"  
共收到 8 条回复

不知道是不是网络的原因,试试看淘宝的rubygem镜像服务: http://ruby.taobao.org/

先安装一下依赖?

$ gem dependency railties

Gem railties-3.0.6
  actionpack (= 3.0.6)
  activesupport (= 3.0.6)
  rake (>= 0.8.7)
  thor (~> 0.14.4)

Gem railties-3.0.10
  actionpack (= 3.0.10)
  activesupport (= 3.0.10)
  rake (>= 0.8.7)
  rdoc (~> 3.4)
  thor (~> 0.14.4)

Gem railties-3.0.11
  actionpack (= 3.0.11)
  activesupport (= 3.0.11)
  rake (>= 0.8.7)
  rdoc (~> 3.4)
  thor (~> 0.14.4)

Gem railties-3.1.1
  actionpack (= 3.1.1)
  activesupport (= 3.1.1)
  rack-ssl (~> 1.3.2)
  rake (>= 0.8.7)
  rdoc (~> 3.4)
  thor (~> 0.14.6)
gem install rdoc -v 3.4
gem install mime-types -v 1.16
gem install treetop -v 1.4.8
gem install hike -v1.2 
gem install tilt -v 1.1

然后再 尝试

gem install rails  

多谢楼上诸位 手动安装所需gem就好了 

我想还是网络的原因可能性比较大,通过 gem 的安装 rails 过程大概是

Step 1: 从 rubygems.org 取得 rails 的metadata中的dependencies Step 2: 发现dependencies中包含了railties,然后递归读取 railties 的metadata中的dependencies Step 3: 直到读取出所有的dependencies,然后按照依赖顺序下载安装

所以我怀疑问题在Step 2, 网络原因嫌疑最大。

#5楼 @lgn21st 我用的是taobao源,昨天瞎试了一天,甚至把rubygems.org删掉,还是出现dependency错误。

#6楼 @wtl 挺奇怪的,我的系统跟你的唯一区别是我用 ruby-1.9.2-p290

#1楼 @lgn21st 我换了sources解决了问题谢谢。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册