Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between bundle and bundle update?

I get two different results when using the two commands bundle and bundle update

If I use bundle update, I get the following error:

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 :

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?

I have always used just bundle, but tried bundle update and noticed the difference.

like image 507
chris Frisina Avatar asked Jun 18 '13 17:06

chris Frisina


2 Answers

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

Needless to say that bundle and bundle install are the same command, install is the default option for bundle.

like image 169
Luís Ramalho Avatar answered Nov 03 '22 21:11

Luís Ramalho


bundle is the same as bundle install, which does the following:

  • Check if a Gemfile.lock exists. 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. Then create the Gemfile.lock to record what versions have been installed.

bundle update on the other hand, deletes / ignores your Gemfile.lock and goes straight to step two.

The error you're seeing is probably because some gem wants active_support to be in the 3.x.x version range, while you seem to be trying to upgrade to Rails 4.

like image 28
Sudhir Jonathan Avatar answered Nov 03 '22 23:11

Sudhir Jonathan