Ruby on rails 捆绑安装—不安装所有依赖项

Ruby on rails 捆绑安装—不安装所有依赖项,ruby-on-rails,rubygems,Ruby On Rails,Rubygems,我使用Mac OS X,当我运行sudo bundle安装时,它会在目标机器上安装几个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]`

我使用Mac OS X,当我运行sudo bundle安装时,它会在目标机器上安装几个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控制台时,我会不断收到越来越多未解决依赖项的输出:

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真的这么难吗?我真的必须一个接一个地手动安装依赖项吗?我做错了什么

  • 删除Gemfile.lock
  • 删除根目录下的所有宝石(首选)
  • 更新rubygems
  • gem安装bundler
  • bundle安装

  • 好的,问题是我不能使用sudo运行bundle安装

    多痛苦啊。为什么这些东西没有记录在什么地方?

    我用过

    bundle update 
    

    它更新了所有gem文件并安装了丢失的gem。没有sudo,因为使用RVM

    如果您使用的是
    Vagrant
    ,请尝试重新启动
    VM
    。经常在工作和家庭之间来回时,我注意到
    VM
    与外部世界的连接被冲洗掉了。在这种情况下,运行
    rails控制台
    会检查任何未满足的依赖项,并会因为无法连接到ruby
    gems.org
    而失败


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

    在MacOSX上,我也遇到了同样的问题。我所需要做的就是:

    gem install bundler
    
    它(在基于Unix的系统上使用相当标准的文档格式,我可以补充);手册页明确指出,在发布
    捆绑安装时不应使用
    sudo