捆绑安装未安装全部依赖项。

4
我正在使用 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个回答

6
  1. 删除 Gemfile.lock
  2. 删除根目录下的所有gems(如果可以的话)
  3. 更新rubygems
  4. gem install bundler
  5. bundle install

6

我使用了

bundle update 

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


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

2
如果你正在使用 Vagrant,请尝试重新启动你的虚拟机(VM)。经常在公司和家之间切换时,我发现虚拟机与外界的连接会出问题。在这种情况下,运行 rails console 将检查是否有未满足的依赖项,并且会因为无法连接到 ruby 的 gems.org 而失败。 这是一个非常糟糕的错误消息,它曾经让我措手不及,而且不止一次。

0

好的,问题在于我不能使用sudo运行bundle install。

真是太麻烦了。为什么这些事情没有被记录在某个地方呢?


11
这个文档记录了(顺便说一下,这是在基于Unix的系统上使用的一种相当标准的文档形式);man页面明确指出,在执行bundle install时不应使用sudo - Michelle Tilley

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接