简体   繁体   English

捆绑包和捆绑包更新有什么区别?

[英]What is the difference between bundle and bundle update?

I get two different results when using the two commands bundle and bundle update 使用两个命令bundlebundle update时,我得到两个不同的结果

If I use bundle update , I get the following error: 如果我使用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)

But if I use just bundle , I get the following : 但如果我只使用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.

The errors point to two different dependencie issues, but both commands are fetching gem metadata from https://rubygems.org/... and Resolving dependencies... , so how are they different? 错误指向两个不同的依赖关系问题,但这两个命令都是fetching gem metadata from https://rubygems.org/...Resolving dependencies... fetching gem metadata from https://rubygems.org/... ,那么它们有何不同?

I have always used just bundle , but tried bundle update and noticed the difference. 我一直只使用bundle ,但尝试bundle update并注意到差异。

In a nutshell: bundle install handles changes to the Gemfile and bundle update upgrades gems that are already managed by Bundler. 简而言之:bundle install处理对Gemfile的更改,并捆绑更新升级已由Bundler管理的gem。

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

Needless to say that bundle and bundle install are the same command, install is the default option for bundle . 不用说bundlebundle install是相同的命令, installbundle的默认选项。

bundle is the same as bundle install , which does the following: bundlebundle install相同,它执行以下操作:

  • Check if a Gemfile.lock exists. 检查Gemfile.lock存在。 If it does, install all gems with the exact versions specified there. 如果是,请安装所有具有指定版本的宝石。
  • If the lock doesn't exist, install gems as specified in the Gemfile , using the latest available / allowable versions according to the Gemfile . 如果锁不存在,请根据Gemfile使用最新的可用/允许版本安装Gemfile指定的Gemfile Then create the Gemfile.lock to record what versions have been installed. 然后创建Gemfile.lock以记录已安装的版本。

bundle update on the other hand, deletes / ignores your Gemfile.lock and goes straight to step two. 另一方面, bundle update ,删除/忽略您的Gemfile.lock并直接进入第二步。

The error you're seeing is probably because some gem wants active_support to be in the 3.xx version range, while you seem to be trying to upgrade to Rails 4. 您看到的错误可能是因为某些gem希望active_support3.xx版本范围内,而您似乎正在尝试升级到Rails 4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM