Bundler: You must use Bundler 2 or greater with this lockfile

I'm working with heroku and every time I try to push my app this message shows out:

remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote:
remote:  !
remote:  !     You must use Bundler 2 or greater with this lockfile.
remote:  !
remote: /tmp/d20181109-104-g861yi/bundler-1.15.2/gems/bundler-1.15.2/lib/bundler/lockfile_parser.rb:108:in `warn_for_outdated_bundler_version': You must use Bundler 2 or greater with this lockfile. (Bundler::LockfileError)
remote:     from /tmp/d20181109-104-g861yi/bundler-1.15.2/gems/bundler-1.15.2/lib/bundler/lockfile_parser.rb:95:in `initialize'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/bundler_wrapper.rb:130:in `new'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/bundler_wrapper.rb:130:in `block in parse_gemfile_lock'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:18:in `block (2 levels) in instrument'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:40:in `yield_with_block_depth'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:17:in `block in instrument'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/vendor/ruby/heroku-18/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/instrument.rb:16:in `instrument'
remote:     from /app/tmp/buildpacks/b7af5642714be4eddaa5f35e2b4c36176b839b4abcd9bfe57ee71c358d71152b4fd2cf925c5b6e6816adee359c4f0f966b663a7f8649b0729509d510091abc07/lib/language_pack/helpers/bundler_wrapper.rb:86:in `instrument'
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to my-proyect-1234.
remote:

It says 'remote: ! You must use Bundler 2 or greater with this lockfile.'

But my Bundler version is 2.0.0.pre.1

Don't know what to do, I tried uninstalling bundle and installing it again, I errased the Gemfile.lock and typing bundle again

131961 次浏览

Heroku 不使用 Bundler 2.0,而是使用1.15.2作为跟踪日志的提示。

据我所知,“变通方法”是创建自己的构建包,或者简单地自己创建:

在编辑器中打开 lib/language _ pack/ruby.rb,并修改以下代码行:

BUNDLER_VERSION = "1.11.2"

(README.md at https://github.com/heroku/heroku-buildpack-ruby)

Update: As of Ruby 2.6.1 and Bundler 2.0.1, Heroku now does support Bundler 2.0.1. https://devcenter.heroku.com/articles/bundler-version#known-upgrade-issues

这就是 Ruby2.6.0的 没有,因为它是从 binstubs 错误地调用的,@Schneems 在注释中提到了这一点。他好心地把这个报告为 Ruby Bug # 15622

我通过运行 gem uninstall bundler删除2.0.0解决了这个问题。重命名 Gemfile.lock 文件(将其从使用中删除) ,然后运行 bundle install重新安装 gemfiles。在我的例子中,我已经访问了 heroku 安装的较早的 bundler 版本(所以当我运行 gem uninstall时,我看到了所有可用的版本,并选择删除2.0.0。前言1)。

I deleted the project and made a git clone from the Heroku app, don´t know if it is a good solution, but it worked for me.

是的,所以通常 uninstalling your version of bundler移除 Gemfile.lock和最后运行 gem install bundler -v 1.15.2(heroku 正在使用的版本)都是有效的。

After that running git push heroku master worked!

虽然有点晚了,但是我今天也遇到了这个问题,这个解决方案避免了卸载 Bundler: 只需运行

heroku buildpacks:set https://github.com/bundler/heroku-buildpack-bundler2

根据对 Bundler 问题的讨论。

在我的本地系统中也出现了同样的问题,由于出现了错误,我的 Ruby 版本很低。通过切换到更新版本的红宝石固定它。

我有同样的问题在本地机器(开发)作为-

您必须对此锁文件使用 Bundler 2或更高版本。
问题出在 锁定上,因为我的本地包版本和项目包版本不匹配! 这是解决方案-

  1. 我删除了 Gemfile.lock
  2. Run the command - bundle install
    这解决了我的问题,它是顺利的! 希望会为别人工作!

Even with bundler 2 on the system this error still happens when deploying an app with Ruby 2.6 since Ruby 2.6 ships with a default version of bundler.

如果您正在使用 Ruby2.6,那么请升级到 Ruby2.6.1以避免这个问题。

For people 他们没有使用 Heroku:

我尝试了所有的东西,我仍然收到这个错误。甚至这个链接没有帮助我: https://github.com/jekyll/jekyll/issues/7463

So this was my solution:

在 GitHub 上推送你的代码。 删除项目文件夹 create a new folder and pull your code bundle install 就是这样 Bundler 最后没有帮我,我也没有用。

还有一件重要的事: 我更新了我的红宝石版本,但是我得到了这个错误,因为我的 RVM 默认版本是旧版本。 even when you use rvm use VERSION_NUMBER -- default will not help because as soon as you log out from terminal the default version will change to the old one and you will have the same issue.

你可以这样回答: 如何使用 RVM 设置默认 Ruby 版本?

或者直接用 rvm uninstall X.X.X卸载旧的红宝石版本,用 rvm install X.X.X安装新版本,然后用 rvm use --default X.X.X默认安装。

干杯。

我也有过类似的经历。

我是这么解决的

为这个 bundler gem 显示所有本地 gem 的列表

gem list bundler

N/B : 上面的命令用于 rbenv 版本管理器,用于 rvm 的命令可能不同

这将显示本地安装的 bundle gem 的版本

bundler (2.1.4, default: 1.17.2)

注意 : 您的版本可能与这里的版本不同

如果您没有在本地安装 bundler version 2,那么运行

gem install bundler

或者

gem install bundler -v 2.1.4

注意 : 用要安装的版本替换 2.1.4

如果您已经在本地安装了 bundle version 2或者刚刚安装了它,那么您只需要在本地安装 RubyGems Package Manager 的更新。要做到这一点,跑

gem update --system

然后终于跑了

bundle update --bundler

用于 Ruby on Rails 中的 Docker 项目

如果您在尝试使用 Docker 构建应用程序时遇到这个问题,只需执行以下操作:

  1. 删除 Gemfile.lock文件

  2. 请通过运行 bundle install重新创建它。

  3. 根据需要运行 docker builddocker-compose build命令来生成项目。

这将重新创建 Gemfile.lock文件,并在 Gemfile.lock文件中设置项目所需的适当版本的 bundle。

不清楚 : 作为附带说明,你也可以将这个环境变量添加到定义了 Bundler 版本的 Dockerfile中。

ENV BUNDLER_VERSION=2.1.4

对于 Ruby2.6.3,我也遇到了同样的问题,答案中没有列出任何有用的东西。 下面唯一的解决办法对我有效:

  1. bundle update rails

  2. Remove Gemfile.lock

  3. bundle

本地系统

gem install bundler:2.0.0.pre.1
bundle _2.0.0.pre.1_ install

其中“2.0.0. pre.1”是您需要捆绑的任何版本。

不要删除你的 Gemfile.lock 为此,它的存在是有原因的

I had the same issue. In my Gemfile.lock i saw at the end "bundled with bundler 2.0.2", but running bundle --version gave me version 1.17... For me it solved just updateing my bundler with the following command: bundle update --bundler 请参阅 bundler 文档

使用 bundler 2.0.1允许根据锁文件的要求自动进行版本切换。在这方面,安装 bundler 2.0.1对我来说很有用。
安装 bundler 2.0.1
gem install bundler -v 2.0.1
更新包
bundle update -bundler

简单的 gem update bundler为我做到了。

如果你使用的是像 FROM:ruby:2.X.X这样的 Docker 图像,那么你可以这样做:

FROM ruby:2.6.2
... # omitted
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN gem uninstall bundler
RUN gem install bundler -v 2.1.4
RUN bundle update --bundler
RUN bundle install
... # omitted

Ruby 2.6.0不是这个问题的症结所在。 使用 bin 存根时错误地调用了 Bundler 的默认版本。 有关详细信息,请参阅以下 < a href = “ https://bugs.ruby-lang.org/questions/15622”rel = “ nofollow noReferrer”> 链接

Solution: Bundler 2 is available on the system and is the latest version, So it should be invoked instead of the default bundler version.

更新 Rubygems

gem update --system

更新包

gem install bundler

更新 Gemfile.lock 中的项目

bundler update --bundler

我今天也遇到了同样的问题。

In my case the problem was caused by using Rvm Gemset other than latest I have with ruby 2.7.1 and bundler 2.1.4 (same bundle Gemfile was locked with).

所以在做任何其他解决方案之前,只需要在 Rvm 环境上使用 看看吧。特别是在生产环境下运行项目时。

Happy hacks !

删除在 Rails 应用程序中安装的 gem 历史记录和模块。

$ rm -rf vendor/bundle
$ rm Gemfile.lock

还有,捆绑

$ bundle install --path=vendor/bundle

然后,启动 Rails Server

$ bundle exec rails s

连接到浏览器。

Http://localhost:3000/

同样的错误,但是是局部的。 最后我发现我在命令行中使用了错误的 Ruby 版本(我使用 uru 来管理 Ruby 版本) After all, how could the gemfile use and produce a lock file with version 2.1.4, yet my search didn't find that version!

>gem list bundler


*** LOCAL GEMS ***


bundler (default: 1.16.2, 1.13.1)
capistrano-bundler (1.6.0, 1.1.4)

So I changed to the correct version of ruby and all was good.

Remember, gems are stored with your Ruby version!