36

When I'm developing/testing, I'm keep getting this error in my console

Warning: the running version of Bundler (2.1.2) is older than the version that created the lockfile (2.1.4). We suggest you to upgrade to the version that created the lockfile by running `gem install bundler:2.1.4`.

It's not blocking me at all but bugging me. I know that easiest solution is just updating my Gemfile.lock to this.

BUNDLED WITH
   2.1.2

But I want to solve this permanently. I try to

gem uninstall bundler

and then

gem install bundler -v 2.1.4

It keeps me giving this error

Gem bundler-2.1.2 cannot be uninstalled because it is a default gem

and when I try to first install 2.1.4 and then delete bundler 2.1.2 console gives me this output.

Gem bundler-2.1.2 cannot be uninstalled because it is a default gem
Successfully uninstalled bundler-2.1.4

Is there any solution to this problem? Thanks in advance

Semih Arslanoglu
  • 1,069
  • 5
  • 20
  • 23

8 Answers8

34

per Anne van Rossum, gem update --system fixed this problem for me.

user1390375
  • 676
  • 6
  • 5
  • 8
    what does this do, and why does this work? – BenKoshy Jan 10 '21 at 22:54
  • 1
    after I run `gem update --system`, I found below bug fixes related to bundler: ## Bug fixes: * Fix broken `bundler` executable after `gem update --system`. Pull request #4221 by deivid-rodriguez * Fix race condition on bundler's parallel installer. Pull request #3440 by David Rodríguez. – karl li Feb 18 '21 at 09:50
21

Just run gem install bundler:2.1.4, don't worry about the older version that comes with ruby, it should not be used.

Igor Kapkov
  • 3,779
  • 2
  • 19
  • 19
  • 1
    After I restart my console, it works exactly you said. Thank you! – Semih Arslanoglu Mar 13 '20 at 13:03
  • 5
    Still get the same error. This is what I do and still get the error. I've tried logging in and out of console and also rebooting Ubuntu. Just installed rails 6.0.2 in ruby 2.7.0. Also tried upgrading to Ubuntu 18.04 hoping for a hail mary. – earth2jason Mar 24 '20 at 05:46
  • 1
    Before running try to delete your Gemfile.lock. It will be created new with selected bundler – Semih Arslanoglu Apr 07 '20 at 07:24
  • 1
    Same problem her, and `rm Gemfile.lock && bundle update && rails s` will still show the same error. Any other suggestion @SemihArslanoğlu? – psychoslave May 15 '20 at 09:57
4

I fixed it!. If you are using rvm, then you have to turn to the ruby version you are using on that particular project (eg. 'rvm use 2.7.0') and then run 'gem update --system'

3

You need to do the following to ensure the correct default version of Bundler is used for the repo you are working with.

  1. You can run the following but this can present issues as it can break your local gems on your system as ALL of them are updated.

    gem update --system
    
  2. The following method is a much safer way of ensuring Bundler is updated

  • Get your gem environment and take note of INSTALLATION_DIRECTORY
    gem environment
    
  • Then run the following
    cd <INSTALLATION DIRECTORY>/specifications/default
    rm bundler-<old_default_version>.gemspec
    gem install --default bundler -v <new_default_version>
    
  1. If you have followed 2 and that still does not work, then run
    gem install bundler:<new_default_version>
    
    to ensure you your local repo is using the correct version
Alexander Swann
  • 619
  • 5
  • 15
0

Another option is to update to the latest version:

gem update bundler

Unless there is a specific reason for using an older version (for example, there is a bug in the latest version, or they are no longer compatible), then you can follow the warning message to just install that particular version:

Warning: the running version of Bundler (2.2.32) is older than the version that created the lockfile (2.3.4). We suggest you to upgrade to the version that created the lockfile by running gem install bundler:2.3.4.

gem install bundler:2.3.4
Yuchen
  • 30,852
  • 26
  • 164
  • 234
0

In my case, this was the only error-message being shown on a failed install. I wasted a lot of time trying to fix it, but it turns out it's just a warning, not an actual error that blocks the install.

To see the actual error message, I had to run bundle install --verbose

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283
0

Ruby ships with a default set of gems. Bundler is one of them. The default version of bundler shipped with your Ruby tends to be outdated soon. To update your standard gems, run

gem update --system

See the RubyGems command reference for more information.

If you don't want to update your standard gems, you can also update Bundler in the context of your bundle (Gemfile.lock). This is possible since Bundler v1.14.

bundle update --bundler

The times of this warning should be over since Bundler v2.3.5 (January 2022). It now automatically fetches the matching remote version and installs it.

Bundler 2.3.17 is running, but your lockfile was generated with 2.3.7. Installing Bundler 2.3.7 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.3.7
Installing bundler 2.3.7
…
schmijos
  • 8,114
  • 3
  • 50
  • 58
-1

I removed gemfile.lock file then bundle again to build new dependencies.

https://github.com/rubygems/rubygems/issues/3202

chickensmitten
  • 477
  • 6
  • 16
  • I don't think this will work in a collaborative repo, this could end up creating more problems, so I'd suggest to go with the approved solution instead – javierojeda Jan 31 '22 at 21:03