We've just updated ruby to 2.6 and bundler to 2. Now we're getting:
# bin/rails console
You must use Bundler 2 or greater with this lockfile.
This was previously happening with bundle exec
:
# bundle exec rails console
You must use Bundler 2 or greater with this lockfile.
At that point we were still running 1.17.2 by default:
# gem list bundler
*** LOCAL GEMS ***
bundler (2.0.1, default: 1.17.2)
So we ran gem uninstall bundler --version 1.17.2
and then bundle exec
started working.
But the bin
stubs like bin/rails
are still failing.
How can it be running 1.17.2
when that's been uninstalled?
Installing Bundler 2 The first step in upgrading to Bundler 2 is installing the Bundler 2 gem. To install it the usual way, run gem install bundler and RubyGems will install the latest version of Bundler.
You have to delete the . gemspec file corresponding to the default gem you want to delete. So first, locate where those files are. Delete the one you don't need.
The diagnose in your answer seems right. But it seems you can activate the latest installed Bundler gem (installed by gem install bundler
) by adding this before the require 'bundler/setup'
line:
Gem::Specification.find_by_name('bundler').activate
More specific version requirements can also be used if needed. For example:
Gem::Specification.find_by_name('bundler', '~> 2.0.1').activate
find_by_name
throws LoadError
derived exception if the gem is not found.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With