Ruby-on-rails Bundler:您必须将 Bundler 2 或更高版本与此锁文件一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53231667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 08:54:11  来源:igfitidea点击:

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

ruby-on-railsherokuruby-on-rails-5heroku-cli

提问by Pedro

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

我正在使用 heroku,每次我尝试推送我的应用程序时都会显示此消息:

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.'

它说'远程:!您必须将此锁定文件使用 Bundler 2 或更高版本。

But my Bundler version is 2.0.0.pre.1

但是我的 Bundler 版本是 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 bundleagain

不知道该怎么办,我尝试卸载 bundle 并重新安装,我擦除了 Gemfile.lock 并bundle再次输入

采纳答案by Pedro

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.

我删除了项目并从 Heroku 应用程序制作了一个 git clone,不知道它是否是一个好的解决方案,但它对我有用。

回答by Promise Preston

I had a similar experience.

我有过类似的经历。

Here's how I solved it

这是我解决的方法

Display a list of all your local gems for the bundler gem

显示 bundler gem 的所有本地 gem 列表

gem list bundler

N/B: The command above is for rbenv version manager, the one for rvm might be different

N/B: 上面的命令是针对 rbenv 版本管理器的,针对 rvm 的可能会有所不同

This will display the versions of the bundler gem installed locally

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

bundler (2.0.2, default: 1.17.2)

if you don't have bundler version 2 installed locally, then run

如果您没有在本地安装 bundler 版本 2,则运行

gem install bundler

OR

或者

gem install bundler -v 2.0.2

if you have bundler version 2 already installed locally or just installed it, then you need to simply install an update for RubyGems Package Manager locally. To do this, run

如果您已经在本地安装了 bundler version 2,或者刚刚安装了它,那么您只需在本地安装 RubyGems Package Manager 的更新。为此,请运行

gem update --system

And then finally run

然后最后运行

bundle update --bundler

For Docker projects in Ruby on Rails

对于 Ruby on Rails 中的 Docker 项目

If you're experiencing this issue when trying to build your application using Docker, simply do this:

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

  1. Delete the Gemfile.lockfile

  2. Please don'tcreate it again by running bundle install.

  3. Run your docker buildor docker-compose buildcommand as appropriate to build your project.

  1. 删除Gemfile.lock文件

  2. 不要通过运行再次创建它bundle install

  3. 根据需要运行您的docker buildordocker-compose build命令来构建您的项目。

This will re-create the Gemfile.lockfile and setup the appropriate version of bundler necessary for your project in the Gemfile.lockfile.

这将重新创建Gemfile.lock文件并在文件中设置您的项目所需的适当版本的捆绑器Gemfile.lock

That's all.

就这样。

I hope this helps.

我希望这有帮助。

回答by Alex

A bit late to the party but I just ran into this today as well, and this solution avoids having to uninstall Bundler: just run

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

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

as per discussion on the Bundler issue here.

根据此处对 Bundler 问题的讨论。

回答by S.Yadav

I had same issue on Local Machine(Development) as-

我在本地机器(开发)上遇到了同样的问题 -

You must use Bundler 2 or greater with this lockfile.
The issue was with gemfile.lockbecause my local bundle version and project bundle version was not matching! Here is solution-

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

  1. I deleted gemfile.lock
  2. Run the command - bundle install
    That solved my problem, it is smooth! Hope will work for others!
  1. 我删除了 gemfile.lock
  2. 运行命令 - bundle install
    这解决了我的问题,很顺利!希望对其他人有用!

回答by Sergey

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.

即使系统上有 bundler 2,在使用 Ruby 2.6 部署应用程序时仍然会发生此错误,因为 Ruby 2.6 附带了默认版本的 bundler。

If you are using Ruby 2.6 then upgrade to Ruby 2.6.1 to avoid this issue.

如果您使用的是 Ruby 2.6,请升级到 Ruby 2.6.1 以避免此问题。

回答by ispirett

simple gem update bundlerdid it for me.

简单gem update bundler为我做了。

回答by Aleksander Jess

Yup, so generally uninstalling your version of bundler, removing the gemfile.lock, and finally running gem install bundler -v 1.15.2(which is the version heroku is using) worked.

是的,所以通常卸载您的 bundler 版本删除 gemfile.lock,最后运行gem install bundler -v 1.15.2(这是 heroku 正在使用的版本)工作。

After that running git push heroku masterworked!

在那之后运行git push heroku master工作!

回答by Arye Eidelman

For local system

对于本地系统

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

Where "2.0.0.pre.1" is whatever version you need to bundle with.

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

Don't delete your Gemfile.lock for this, it's there for a reason.

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

回答by John Creamer

I resolved this issue by running gem uninstall bundlerto remove 2.0.0.pre.1, renamed the Gemfile.lock file (to remove it from use) and then ran bundle installto reinstall the gemfiles. In my case, I already had access to the earlier bundler version installed by heroku (so when I ran gem uninstall, I was shown all versions available and chose to remove 2.0.0.pre.1).

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

回答by Frederik Spang

Heroku does not use Bundler 2.0, but 1.15.2, as the tracelog hints.

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

As far as I am aware, the "workaround" is to create your own buildpack, or simple fork their own:

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

Open lib/language_pack/ruby.rb in your editor, and change the following line:

BUNDLER_VERSION = "1.11.2"

在编辑器中打开 lib/language_pack/ruby.rb,并更改以下行:

BUNDLER_VERSION = "1.11.2"

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

(README.md 在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

更新:从 Ruby 2.6.1 和 Bundler 2.0.1 开始,Heroku 现在支持 Bundler 2.0.1。https://devcenter.heroku.com/articles/bundler-version#known-upgrade-issues

This is notthe case for Ruby 2.6.0, as this is incorrectly invoked from binstubs, as @Schneems has mentioned in the comment. He has kindly reported this as a Ruby Bug #15622

不是Ruby 2.6.0 的情况,因为这是从 binstubs 错误地调用的,正如@Schneems 在评论中提到的那样。他亲切地将此报告为Ruby Bug #15622

回答by Timo Moss

I got the same problem for Ruby 2.6.3, nothing listed in answers could help. The only the following solution worked for me:

我在 Ruby 2.6.3 上遇到了同样的问题,答案中列出的任何内容都没有帮助。以下唯一的解决方案对我有用:

  1. bundle update rails

  2. Remove Gemfile.lock

  3. bundle

  1. bundle update rails

  2. 删除 Gemfile.lock

  3. bundle