bundle installするとcan't find gem bundlerと言われる

bundle installするとcan't find gem bundlerとエラーが表示される

$ bundle install --path=vendor/bundle
Traceback (most recent call last):
    2: from /Users/nullpon/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
    1: from /Users/nullpon/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/Users/nullpon/.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)

bundlerのバージョンとGemfile.lockのバージョンの相違が原因のようだが・・・

$ bundle -v
Bundler version 2.0.1
$ tail -2  Gemfile.lock
BUNDLED WITH
   1.15.4

Gemfile.lockの指定より後のバージョンのbundlerならば実行できるはずなのだが、メジャーバージョンが変わるとダメなのだろうか?

面倒なのでGemfile.lockを書き換えちゃおう。

$ diff --git a/Gemfile.lock b/Gemfile.lock
index a7e9509..278939d 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -200,4 +200,4 @@ DEPENDENCIES
  web-console (>= 3.3.0)

 BUNDLED WITH
-   1.15.4
+   2.0.1

これで実行できるようになりました。