How to fix "Warning: the running version of Bundler is older than the version that created the lockfile" - ruby

I have tried multiple times to uninstall bundler and reinstall bundler, and somehow, I keep seeing this error:
➜ gem uninstall bundler
Remove executables:
bundler
in addition to the gem? [Yn] y
Removing bundler
Successfully uninstalled bundler-2.0.1
➜ gem install bundler
Fetching: bundler-2.0.1.gem (100%)
Successfully installed bundler-2.0.1
1 gem installed
➜ bundle
Warning: the running version of Bundler (1.16.6) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.

Just uninstall and install again the required version in the warning, in your case it is requiring version 1.17.3
gem uninstall bundler
gem install bundler -v 1.17.3

Related

Can't run bundle install: Bundler could not find compatible versions for gem "bundler"

I'm trying to run bundle install, but I keep getting this error:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
bundler (~> 2.1.4)
Current Bundler version:
bundler (2.2.29)
Your bundle requires a different version of Bundler than the one you're running.
Install the necessary version with `gem install bundler:2.1.4` and rerun bundler
using `bundle _2.1.4_ install`
Tried an update and cleanup. Nothing has worked. Had tons of issues like this ever since updating to Catalina.

bundler version claims to exist, but does not

How can this be explained and remedied?
-bash> gem list bundler
*** LOCAL GEMS ***
bundler (default: 2.2.21)
-bash> bundler --version
Bundler version 2.1.4
-bash> gem uninstall bundler:2.1.4
Gem 'bundler' is not installed
-bash> gem environment | grep INSTALL
- INSTALLATION DIRECTORY: /Users/me/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/me/.gem/ruby/2.7.0
-bash> find /Users/me/.rbenv/versions/2.7.4/ -name "bundler*"
/Users/me/.rbenv/versions/2.7.4//bin/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/rubygems/bundler_version_finder.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/exe/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/bundler.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/2.7.0/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/specifications/default/bundler-2.2.21.gemspec
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/cache/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/cache/bundler-2.2.21.gem
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/doc/bundler-2.2.21
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/doc/bundler-2.2.27
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bootsnap-1.8.1/lib/bootsnap/bundler.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bundler-2.2.21
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bundler-2.2.21/exe/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/rubocop-1.13.0/lib/rubocop/cop/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/bootsnap-1.7.4/lib/bootsnap/bundler.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/rubocop-1.21.0/lib/rubocop/cop/bundler
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/gems/simplecov-0.17.1/lib/simplecov/profiles/bundler_filter.rb
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/bundler
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/LockfileParser/bundler_version-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/bundler_major_version-c.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/Standalone/bundler_path-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/Plugin/API/Source/bundler_plugin_api_source%3f-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/Fetcher/bundler_cert_store-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/CLI/Gem/bundler_dependency_version-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Bundler/SharedHelpers/bundler_ruby_lib-i.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Gem/BundlerVersionFinder/bundler_version_with_reason-c.ri
/Users/me/.rbenv/versions/2.7.4//share/ri/2.7.0/system/Gem/BundlerVersionFinder/bundler_version-c.ri
I cannot explain it, but the remedy is:
Remove bundler-2.2.21.gemspec from the folder that renders it default:
Reinstall the desired version.
Uninstalling bundler will not work:
-bash> gem uninstall bundler
Gem bundler-2.2.21 cannot be uninstalled because it is a default gem
Note the following line in the output of the find command above:
/Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/specifications/default/bundler-2.2.21.gemspec
Remove it in order to remove the "default" status of this gem:
rm /Users/me/.rbenv/versions/2.7.4//lib/ruby/gems/2.7.0/specifications/default/bundler-2.2.21.gemspec
Uninstalling is now impossible...
-bash> gem uninstall bundler
Gem 'bundler' is not installed
Indeed...
-bash> bundler --version
Traceback (most recent call last):
2: from /Users/me/.rbenv/versions/2.7.4/bin/bundler:23:in `<main>'
1: from /Users/me/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/Users/me/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': Could not find 'bundler' (2.1.4) required by your /Users/me/Projects/kinside/kinside/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.4`
So install the desired version:
-bash> gem install bundler:2.2.21
Successfully installed bundler-2.2.21
Parsing documentation for bundler-2.2.21
Installing ri documentation for bundler-2.2.21
Done installing documentation for bundler after 3 seconds
1 gem installed
Check:
-bash> bundler --version
Bundler version 2.2.21
-bash> gem list bundler
*** LOCAL GEMS ***
bundler (2.2.21)

sudo msfconsole [*] Bundler failed to load and returned this error: help me

┌─[alzaeem#Parrot]─[~/tools]
└──╼ $sudo msfconsole
[*] Bundler failed to load and returned this error:
'You have already activated bundler 2.1.4, but your Gemfile requires bundler 2.2.3. Since bundler is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports bundler as a default gem.'
[*] You may need to uninstall or upgrade bundler
you have to update your bundler version, in this case:
gem install bundler -v 2.2.3
for other gems
gem install 'gem name' -v 'version'

after bundler installed with specific version why version of bundler did not change?

I got following error for bundle
Bundler could not find compatible versions for gem "bundler": In
Gemfile:
bundler (~> 1.15)
Current Bundler version:
bundler (2.0.1) This Gemfile requires a different version of Bundler. Perhaps you need to update Bundler by running gem install
bundler?
Could not find gem 'bundler (~> 1.15)' in any of the relevant sources:
the local ruby installation
then I tried to downgrade the bundler version with
$ gem install bundler -v '~> 1.7.0' Fetching: bundler-1.7.15.gem
(100%) Successfully installed bundler-1.7.15 Parsing documentation for
bundler-1.7.15 Installing ri documentation for bundler-1.7.15 Done
installing documentation for bundler after 1 seconds 1 gem installed
but when I recheck the bundler version with
bundler --version
it still said Bundler version 2.0.1
The default bundler version on your system is still 2.0.1. If you need to use the downloaded version 1.7.15, you would have to run bundle _1.7.15_ install. You could also check if that version was successfully installed on your system using bundle _1.7.15_ -v
In either case, if you get the error Could not find command "_1.7.15_", then that means that the bundler version _1.7.15_ has not been installed on your system.
Additionally, these links may help you:
Run specific version of bundler
Downgrade Bundler in RVM
Try updating bundle with bundler update bundler and run the bundle update again. It solved my problem the last time.

'gem install -v' installs wrong version of a gem

I'd like to install bundler v1.2.3 on my machine.
First, I checked out the remote gem repo whether that version of the gem exists:
$ gem list --remote | grep "^bundler "
bundler (1.2.3)
Then I tried to install the gem, but a different version(v1.1.5):
$ sudo gem install bundler -v '1.2.3'
Successfully installed bundler-1.1.5
1 gem installed
Installing ri documentation for bundler-1.1.5...
Installing RDoc documentation for bundler-1.1.5...
Why is this happening and is there any solution for this problem?
Thanks!
Just tested on my Mac running 10.8, worked no problem. I had Bundler 1.3.5 already installed.
andys-MacBook-Pro:.gem uw$ gem list 'bundler'
*** LOCAL GEMS ***
bundler (1.3.5)
andys-MacBook-Pro:.gem uw$ gem install 'bundler' -v '1.2.3'
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
Parsing documentation for bundler-1.2.3
Installing ri documentation for bundler-1.2.3
1 gem installed
I'm getting the gem (bundler 1.2.3) installed properly in my Win 7 32 bit machine. give a try again
C:\Windows\System32>gem install bundler -v 1.2.3
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
1 gem installed
Installing ri documentation for bundler-1.2.3...
Installing RDoc documentation for bundler-1.2.3...
When I used gem install bundler '1.2.3'
I got the following.
PS C:\Users\....> gem install bundler '1.2.3'
Fetching: bundler-1.2.3.gem (100%)
Successfully installed bundler-1.2.3
ERROR: Could not find a valid gem '1.2.3' (>= 0) in any repository
But it worked fine when I remove the quotation marks and just used
gem install bundler 1.2.3
EDIT ~ Didn't see the comment to the previous answer. Looks like this question is already solved.
I noticed that you use sudo to do the install but not to do the list. This can sometimes cause a problem, especially if you have multiple versions of ruby/gem installed (or if you use rvm).
I've also seen oddities like this if one of the gems is not using rubygems.org as the default gemserver. What does $ sudo gem list --remote | grep "^bundler " give you?
It may not matter but what version of ruby are you using?

Resources