Semih Arslanoglu
Semih Arslanoglu

Reputation: 1139

Warning: the running version of Bundler is older than the version that created the lockfile error

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

Upvotes: 41

Views: 45043

Answers (8)

user1390375
user1390375

Reputation: 736

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

Upvotes: 38

schmijos
schmijos

Reputation: 8695

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
…

Upvotes: 3

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

Upvotes: 0

Yuchen
Yuchen

Reputation: 33046

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

Upvotes: 0

chickensmitten
chickensmitten

Reputation: 495

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

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

Upvotes: -2

Alexander Swann
Alexander Swann

Reputation: 639

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

Upvotes: 3

Diego Amaya
Diego Amaya

Reputation: 79

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'

Upvotes: 5

Igor Kapkov
Igor Kapkov

Reputation: 3909

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

Upvotes: 24

Related Questions