find_spec_for_exe': can't find gem bundler (>= 0.a) (Gem::GemNotFoundException)
Solution 1:
The problem in my case is that the Gemfile.lock
file had a BUNDLED_WITH
version of 1.16.1
and gem install bundler
installed version 2.0.1
, so there was a version mismatch when looking to right the folder
gem install bundler -v 1.16.1
fixed it
Of course, you can also change your Gemfile.lock
's BUNDLED_WITH
with last bundler
version and use recent software, as Sam3000 suggests
Solution 2:
gem update --system
will update the rubygems and will fix the problem.
Solution 3:
Update:
According @noraj's answer and @Niels Kristian's comment, the following command should do the job.
gem update --system
bundle install
I wrote this in case someone gets into an issue like mine.
gem install bundler
shows that everythings installs well.
Fetching: bundler-1.16.0.gem (100%)
Successfully installed bundler-1.16.0
Parsing documentation for bundler-1.16.0
Installing ri documentation for bundler-1.16.0
Done installing documentation for bundler after 7 seconds
1 gem installed
When I typed bundle
there was an error:
/Users/nikkov/.rvm/gems/ruby-2.4.0/bin/bundle:23:in `load': cannot load such file -- /Users/nikkov/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/bundler-1.16.0/exe/bundle (LoadError)
from /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/bundle:23:in `<main>'
from /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/nikkov/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
And in the folder /Users/nikkov/.rvm/rubies/ruby-2.4.0/lib/ruby/gems/2.4.0/gems/
there wasn't a bundler-1.16.0
folder.
I fixed this with sudo gem install bundler
Solution 4:
This fixed it:
- Remove Gemfile.lock
rm Gemfile.lock
- run
bundle install
again
EDIT: DON'T DO IT IN PRODUCTION!
For production go to this answer: https://stackoverflow.com/posts/54083113/revisions
Solution 5:
The real answer is here if you try to install bundler 2.0.1 or 2.0.0 due to Bundler requiring RubyGems v3.0.0
Yesterday I released Bundler 2.0 that introduced a number of breaking changes. One of the those changes was setting Bundler to require RubyGems v3.0.0. After making the release, it has become clear that lots of our users are running into issues with Bundler 2 requiring a really new version of RubyGems.
We have been listening closely to feedback from users and have decided to relax the RubyGems requirement to v2.5.0 at minimum. We have released a new Bundler version, v2.0.1, that adjusts this requirement.
For more info, see: https://bundler.io/blog/2019/01/04/an-update-on-the-bundler-2-release.html