bundle install不安装所有依赖项

时间:2011-08-14 22:14:08

标签: ruby-on-rails rubygems

我在Mac OS X上,当我运行sudo bundle install时,它会在目标机器上安装几个gem:

Installing ptools (1.2.1) 
Using thor (0.14.6) 
Using railties (3.0.5) 
Using rails (3.0.5) 
Installing rails_config (0.2.4) 
Using shoulda (2.11.3) 
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
imac-cf:gnymbus apple$ rails console
Could not find rake-0.9.2 in any of the sources
imac-cf:gnymbus apple$ sudo gem install rake-0.9.2
ERROR:  Could not find a valid gem 'rake-0.9.2' (>= 0) in any repository
imac-cf:gnymbus apple$ sudo gem install rake -v=0.9.2
Successfully installed rake-0.9.2
1 gem installed
Installing ri documentation for rake-0.9.2...
Installing RDoc documentation for rake-0.9.2...
imac-cf:gnymbus apple$ sudo gem install rake-0.9.2
^CERROR:  Interrupted
imac-cf:gnymbus apple$ rails console
Could not find i18n-0.6.0 in any of the sources
imac-cf:gnymbus apple$ sduo gem install i18n -v=0.6.0
-bash: sduo: command not found
imac-cf:gnymbus apple$ sudo gem install i18n -v=0.6.0
Successfully installed i18n-0.6.0
1 gem installed
Installing ri documentation for i18n-0.6.0...
Installing RDoc documentation for i18n-0.6.0...

因此,应该可以安全地假设已经为应用程序解析了依赖关系,并且已经准备好了。但他们不是。

当我运行rails console时,我会不断收到有关越来越多未解决的依赖项的输出:

imac-cf:gnymbus apple$ rails console
Could not find tzinfo-0.3.29 in any of the sources
imac-cf:gnymbus apple$ sudo gem install tzingo -v=0.3.29
ERROR:  Could not find a valid gem 'tzingo' (= 0.3.29) in any repository
imac-cf:gnymbus apple$ sudo gem install tzinfo -v=0.3.29
Successfully installed tzinfo-0.3.29
1 gem installed
Installing ri documentation for tzinfo-0.3.29...
Installing RDoc documentation for tzinfo-0.3.29...
imac-cf:gnymbus apple$ rails console
Could not find polyglot-0.3.2 in any of the sources
imac-cf:gnymbus apple$ sudo gem install polyglot -v=0.3.2
Successfully installed polyglot-0.3.2
1 gem installed
Installing ri documentation for polyglot-0.3.2...
Installing RDoc documentation for polyglot-0.3.2...
imac-cf:gnymbus apple$ rails console
Could not find treetop-1.4.10 in any of the sources
imac-cf:gnymbus apple$ sudo gem install treetop -v=1.4.10
Successfully installed treetop-1.4.10
1 gem installed
Installing ri documentation for treetop-1.4.10...
Installing RDoc documentation for treetop-1.4.10...
imac-cf:gnymbus apple$ rails console
Could not find mail-2.2.19 in any of the sources
imac-cf:gnymbus apple$ sudo gem install mail -v=2.2.19
Successfully installed mail-2.2.19
1 gem installed
Installing ri documentation for mail-2.2.19...
Installing RDoc documentation for mail-2.2.19...
imac-cf:gnymbus apple$ rails console
Could not find addressable-2.2.6 in any of the sources

Rails真的很难吗?我是否真的必须逐个手动安装依赖项?我做错了什么?

5 个答案:

答案 0 :(得分:6)

  1. 删除 Gemfile.lock
  2. 删除root下的所有宝石(不喜欢)
  3. 更新rubygems
  4. gem install bundler
  5. bundle install

答案 1 :(得分:5)

我用过

bundle update 

它更新了所有Gemfiles并安装了缺失的宝石。没有sudo,因为使用RVM

答案 2 :(得分:2)

在Mac OSX上,我遇到了同样的问题。我需要做的就是:

gem install bundler

答案 3 :(得分:1)

如果您使用的是Vagrant,请尝试重新启动VM。通常在工作和家庭之间来回走动时,我注意到VM与外界的联系得到了冲击。在这种情况下,运行rails console将检查是否存在任何未满足的依赖项,并且因为无法连接到ruby gems.org而失败。

这是一个非常糟糕的错误信息,不止一次让我措手不及。

答案 4 :(得分:0)

好的,问题是我不得不使用sudo运行bundle install。

多么痛苦。为什么这些东西没有在某处记录?