Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The bundle currently has rails locked at 4.0.4

In Gemfile I made the following change:

-bash> git diff Gemfile
...
-gem 'rails', '4.0.4'
+gem 'rails', '4.0.5'

I then ran bundle and got a show-stopping message:

-bash> bundle
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
You have requested:
  rails = 4.0.5

The bundle currently has rails locked at 4.0.4.
Try running `bundle update rails`

I then ran bundle update rails, as per the above message, and got the following (note that I am skipping lines without change).

-bash> bundle update rails
Fetching gem metadata from https://rubygems.org/........
Fetching additional metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 10.3.2 (was 10.3.0)
Installing multi_json 1.10.1 (was 1.9.2)
Installing activesupport 4.0.5 (was 4.0.4)
Installing actionpack 4.0.5 (was 4.0.4)
Installing actionmailer 4.0.5 (was 4.0.4)
Installing activemodel 4.0.5 (was 4.0.4)
Using activerecord-deprecated_finders 1.0.3
Installing activerecord 4.0.5 (was 4.0.4)
Installing railties 4.0.5 (was 4.0.4)
Installing rails 4.0.5 (was 4.0.4)
Your bundle is updated!

Question: Is this the expected behaviour? According to another user, I expected to see what is locking the version.

Question: Why was rails locked? And is there a better way of dealing with this situation than what I did?

like image 697
user664833 Avatar asked May 27 '14 05:05

user664833


1 Answers

Is this the expected behaviour?

Yes. Gems have dependencies. When you update a gem, it gets its updated dependencies (in case of rails, it is its active* parts, for example).

This is an output of successful bundle update, by the way. Which means that there were no conflicts in dependency resolution. If there were a conflict, you'd see that instead. (something like 'gem A requires gem B v1.2.3, but gem C uses gem B v4.5.6').

Why was rails locked?

Because Gemfile.lock specified rails version 4.0.4. And it is this version (from lock file) that will be used by bundler, on deploys, etc. Simply changing version in a Gemfile will not affect which gem version is loaded. bundle install / bundle update is needed.

Update

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

Here are the rules:

  1. Always use bundle install
  2. If you need to upgrade a dependency that Bundler is already managing, use bundle update gem_name.
  3. Don't run bundle update unless you want all of your gems to be upgraded.
like image 118
Sergio Tulentsev Avatar answered Sep 27 '22 19:09

Sergio Tulentsev