2

When I add a gem to a project's Gemfile for the first time, but I have installed the gem previously while working on another project, it uses the existing version of the gem, rather than the latest version of the gem available.

For example, using bundler version 1.11.2, I added gem 'rubocop' to a project's Gemfile, and running bundle install resulted in it using RuboCop version 0.42.0, rather than the current (as of 21 October 2016) version of 0.44.1:

rubocop (0.42.0)
  parser (>= 2.3.1.1, < 3.0)
  powerpack (~> 0.1)
  rainbow (>= 1.99.1, < 3.0)
  ruby-progressbar (~> 1.7)
  unicode-display_width (~> 1.0, >= 1.0.1)

Running bundle update rubocop resulted in version 0.44.1 being used, without any pre-existing gems having their version changed. This indicates there weren't any constraints shopping me from using RuboCop version 0.44.1.

rubocop (0.44.1)
  parser (>= 2.3.1.1, < 3.0)
  powerpack (~> 0.1)
  rainbow (>= 1.99.1, < 3.0)
  ruby-progressbar (~> 1.7)
  unicode-display_width (~> 1.0, >= 1.0.1)

When running bundle install, how can I tell it, for gems that aren't mentioned in Gemfile.lock, to download the newest compatible version of the gem, rather than use an older version which happens to be available on the local machine?

I tried looking at http://bundler.io/v1.13/man/bundle-install.1.html but nothing there seemed to be relevant.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338

1 Answers1

0

If you want to have newest version gem, remove version in Gemfile and run bundle install again.

  • I've added an example reproduction to my question, suggesting that this approach won't work, at least for the version of bundler I was using. – Andrew Grimm Oct 21 '16 at 02:45