2013-06-18 47 views
4

我用两个命令bundlebundle update捆绑和捆绑更新有什么区别?

时得到两个不同的结果,如果我使用bundle update,我得到以下错误:

Resolving dependencies... 
Bundler could not find compatible versions for gem "railties": 
    In Gemfile: 
    requirejs-rails (>= 0) ruby depends on 
     railties (~> 3.1.1) ruby 

    rails (= 4.0.0.rc2) ruby depends on 
     railties (4.0.0.rc2) 

Bundler could not find compatible versions for gem "rails": 
    In Gemfile: 
    requirejs-rails (>= 0) ruby depends on 
     rails (~> 3.1.1) ruby 

    rails (4.0.0.rc2) 

但如果我只使用bundle,我得到如下:

Resolving dependencies... 
Bundler could not find compatible versions for gem "activesupport": 
    In snapshot (Gemfile.lock): 
    activesupport (3.2.2) 

    In Gemfile: 
    rails (= 4.0.0.rc2) ruby depends on 
     activesupport (= 4.0.0.rc2) ruby 

Running `bundle update` will rebuild your snapshot from scratch, using only 
the gems in your Gemfile, which may resolve the conflict. 

错误指向两个不同的相关问题,但这两个命令是fetching gem metadata from https://rubygems.org/...Resolving dependencies...,他们有什么不同?

我一直只使用bundle,但试过bundle update,注意到不同之处。

回答

9

In a nutshell: bundle install handles changes to the Gemfile and bundle update upgrades gems that are already managed by Bundler.

http://viget.com/extend/bundler-best-practices

不用说,bundlebundle install是相同的命令,installbundle的默认选项。

5

bundle相同bundle install,其执行以下操作:

  • 检查是否存在Gemfile.lock。如果是这样,请安装所有精确版本的宝石。
  • 如果锁不存在,请根据Gemfile使用最新的可用/允许版本安装Gemfile中指定的宝石。然后创建Gemfile.lock以记录已安装的版本。

bundle update另一方面,删除/忽略您的Gemfile.lock并直接进入第二步。

你看到的错误可能是因为一些宝石要active_support是在3.x.x版本范围,而你似乎想要升级到Rails的4