[RUBY] can't find gem bundler (> = 0.a) with executable bundle workaround

I get this error when I clone an existing Rails project and do a % bundle install.

% bundle install

Traceback (most recent call last):
       2: from /Users/trilingual/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
       1: from /Users/trilingual/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/triringual/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

Cause

The cause is that the description of BUNDLED WITH 2.0.2 at the bottom of Gemfile.lock is different from the version of bundler installed by itself.

Gemfile.lock


<abridgement>
BUNDLED WITH
2.1.4

With this

% bundler -v
Bundler version 1.17.1

This is different.

solution

(1) Check the description of BUNDLED WITH ○○ at the bottom of Gemfile.lock of the application.

Gemfile.lock


<abridgement>
BUNDLED WITH
2.1.4

(2) Install the version described in Gemfile.lock (2.1.4 this time)

% gem install bundler -v 2.1.4

Summary

Envisioned environment of application and Environment of own PC It is an image that I will match. ・ When you buy a new PC and open the app ・ When you git clone the app ・ When changing the version of Ruby I feel that this error occurs frequently with a pattern like.

May it reach those who have the same error!

Recommended Posts

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