medBouzid
medBouzid

Reputation: 8392

Is it necessary to update the line of gem in Gemfile when using bundle update gem-name?

I want to update my jquery_rails gem, actual version is 3.0.4, the following command will update it

bundle update jquery_rails

so, what about my Gemfile, it is necessary to update version of jquery_rails too ? ("i work currently in local")

in my Gemfile i have version 2.2.1

gem 'jquery-rails', '2.2.1'

Update

i change gem 'jquery-rails', '2.2.1' in my Gemfile to gem 'jquery-rails', '3.0.4', and i tried to execute bundle update jquery-railsbut an error is occur :

 Bundler could not find compatible versions for gem "railties":
In Gemfile:
rails (= 4.0.0) ruby depends on
  railties (= 4.0.0) ruby

sass-rails (= 4.0.0) ruby depends on
  railties (4.0.1)

Upvotes: 0

Views: 167

Answers (2)

Tim Moore
Tim Moore

Reputation: 9482

To answer your question directly, in this case yes it is necessary to update the version in Gemfile, but it is not always.

Running bundle update <gem> will cause Bundler to find the most recent version of the gem and its dependencies that satisfies all of the requirements of the Gemfile. Since you have specified a requirement of a specific version, Bundler will only allow that version. You can also specify a more flexible version in your Gemfile: gem 'jquery-rails', '~> 2.2.0' would allow it to use any 2.2.x version, or '~> 2.2' would allow any 2.x.

The issue with sass-rails is separate. You can solve it by updating to sass-rails 4.0.1. See can't get gemfile to allow for bundle update

Upvotes: 0

alexmac
alexmac

Reputation: 19607

Firstly, you should update your gem file and specify required version of the gem, then run bundle update jquery_rails.

Error tells you, that you have gems which required different version of railties. Try to change versions of rails to 4.0.1, sass-rails to 4.0.1 and railties to 4.0.1 and update these gems via bundle.

Upvotes: 1

Related Questions