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

问题

在使用Bundler对项目依赖作管理时,使用:bash

bundle installui

会报错:spa

can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException) 复制代码

缘由

Bundler2中添加了一个新特性,根据lockfile自动切换Bundler版本。这个特性在RubyGems的版本号大于2.7.0时会生效。可是会有一个bug,须要指定Bundler版本号。code

解决方案

使用命令:get

gem install bundler -v '1.17.3'
复制代码

就能够了。string

若是仍然遇到报错:it

You don't have write permissions for the ... 复制代码

须要得到权限,能够使用命令:io

sudo gem install bundler -v '1.17.3' -n /usr/local/bin
复制代码

成功以后再执行再bundle install就行了。table

参考

Update the bundler commandclass

use -n parameter to install