Fix: can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
When I tried to run bundle install in an environment with multiple Ruby versions managed by rbenv, I hit the following error.
1 | can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) |
- The Ruby version was correct,
- the Gemfile was there,
- and I had run
gem install bundlerso bundle existed too ← this was the problem
yet I still got the error.
I kept getting stuck on this, so I took some notes for future reference.
Conclusion
It was caused by the bundler version (2.0.2) differing from the one in Gemfile.lock (1.17.1).
- The bundler installed via gem was
2.0.2
1 | $ gem install bundler |
- The bundler in Gemfile.lock was
1.17.1
1 | ... |
So once I matched the bundle version being executed to the one in Gemfile.lock, it ran fine.
Fix
1 | $ gem install bundler -v 1.17.1 |
At first glance, (>= 0.a) made me go “huh?”, and thinking “wait, I did set it up though…” is exactly how you get stuck. This was something I wanted to be able to recognize the moment I see this error message.
That’s all.
I hope you find it helpful.
Fix: can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)