Monday, 17 June 2019

You must use Bundler 2 or greater with this lockfile.

I have been getting this error recently when doing some things, but not others... These worked:

rails c

rails test

rails test:models

These failed:
jruby -S rake test:models

jruby -S rails test:models

jruby test/models/db_section_test.rb

The error message suggests it is using an earlier version of Bundler, so I spent ages hunting down any rogue version, deleting old versions of JRuby, searching folders and gemfiles. Version 2.0.1 was definitely the only one, so how come it was complaining?

I was also suspicious of JRuby.

Eventually I found a Github discussion for bundler, with the solution buried pretty deep. This seemed to fix it.

gem update --system

bundle (not sure if this was needed)

gem install bundler

Once gem was updated, a new bundler version was available, 2.0.2, and all seemed well at first, but I layter hit upon this:

Gem::GemNotFoundException: can't find gem bundler (>= 0.a) with executable bundle

This seems to occur because JRuby 9.2.7 comes with a slightly older version of Gem, one that cannot run Bundler 2.0.2 (is there really so big a difference between 2.0.1 and 2.0.2?).

I never got this to work, and the only solution was to start from scratch, re-installing JRuby, and install Bundler version 1.16.6.

Updated gem is a bad idea too, as it them tries to run ruby.exe, rather than jruby.exe.

I guess you need to use a modified version of gem for JRuby, which currently is still on 2.0.1 or equivalent, and that means if you are using JRuby, stick with Bundler 1.16.6 for now.