Ruby-on-rails 部署到heroku时如何解决rails中的更新捆绑器警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37375215/
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 00:25:28  来源:igfitidea点击:

How to solve the update bundler warning in rails when deploying to heroku?

ruby-on-railsrubyherokubundlerrailstutorial.org

提问by LovingRails

How do I solve the following warning? I updated my ruby version to 2.3.1 and rails version to 4.2.6. I get this warning when I push my app to heroku.

如何解决以下警告?我将 ruby​​ 版本更新为 2.3.1,将 rails 版本更新为 4.2.6。当我将我的应用程序推送到 heroku 时,我收到此警告。

remote:        Cleaning up the bundler cache.
remote:        Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote:        Removing mime-types-data (3.2016.0221)

I removed the Gemfile.lock and ran bundle install and also tried to update the bundler but the warning never goes away .

我删除了 Gemfile.lock 并运行了 bundle install 并尝试更新 bundler 但警告永远不会消失。

suramai@rails-tutorial:~/workspace/converse (master) $ gem install bundler
Successfully installed bundler-1.12.4
1 gem installed
suramai@rails-tutorial:~/workspace/converse (master) $

回答by jrochkind

So it's complaining that the version of bundler installed on heroku is older than the version you used to create your Gemfile.lockon your dev machine.

所以它抱怨安装在 heroku 上的 bundler 版本比你用来Gemfile.lock在你的开发机器上创建的版本旧。

You can probably just ignore the warning -- in most cases installing with a slightly older version of bundler than you used to create the Gemfile.lockis just fine.

您可能可以忽略该警告——在大多数情况下,使用比您创建时使用的版本稍旧的捆绑程序安装Gemfile.lock就可以了。

bundler recently added the recording of the version of bundler used in the Gemfile.lock, and then the subsequent warning, because in some cases a new feature added to a new version of bundler might have been used to create the Gemfile.lock, such that installing with an older version might not work right. So sometimes it can be a problem. Although usually it won't be.

bundler 最近添加了 中使用的 bundler 版本的记录Gemfile.lock,然后是随后的警告,因为在某些情况下,添加到新版本 bundler 的新功能可能已用于创建Gemfile.lock,因此使用旧版本安装可能会不能正常工作。所以有时这可能是一个问题。虽然通常不会。

It doesn't look like you can get heroku to install with a different version of bundler.

看起来您无法使用不同版本的 bundler 安装 heroku

If you want to make the warning go away, you could instead choose to use the same version of bundler locally that heroku uses. It's a bit hard to figure out exactly what version of bundler heroku is using -- it would be nice if that warning line actually told you the two different versions of bundler involved! But it doesn't.

如果您想让警告消失,您可以选择在本地使用与 heroku 使用的捆绑程序版本相同的版本。要弄清楚 heroku 正在使用哪个版本的 bundler 有点困难——如果该警告行实际上告诉您所涉及的两个不同版本的 bundler,那就太好了!但事实并非如此。

This heroku support docsuggests that heroku is using bundler 1.11.2. (Right now; it could change in the future!). We can see from your log that you are using 1.12.4. If you want to use 1.11.2instead, to avoid the warning, then, remove all versions of bundler installed on your system:

这个 heroku 支持文档表明 heroku 正在使用 bundler 1.11.2。(现在;将来可能会改变!)。我们可以从您的日志中看到您正在使用1.12.4. 如果您想1.11.2改用,为了避免出现警告,请删除系统上安装的所有版本的 bundler:

 gem uninstall bundler

Then install 1.11.2specifically:

然后1.11.2具体安装:

 gem install bundler -v 1.11.2

In general, when you use the bundlecommand, it will use the latest version installed on your system, so to make sure you are always using 1.11.2, make sure that's the latest version installed on your system, and never install a later one.

通常,当您使用该bundle命令时,它将使用您系统上安装的最新版本,因此为确保您始终使用1.11.2,请确保这是您系统上安装的最新版本,并且永远不要安装更高版本。

Then you need to regenerate your Gemfile.locksuch that it says it was bundled with 1.11.2, to not get the warning anymore. This is kind of pain, the easiest thing to do might be to edit the Gemfile.lockby hand, and then going forward only ever use bundler 1.11.2.

然后你需要重新生成你的Gemfile.lock,它说它与 捆绑在一起1.11.2,不再收到警告。这是一种痛苦,最简单的方法可能是Gemfile.lock手动编辑,然后继续使用 bundler 1.11.2

To use bundler 1.11.2even if you do want to have later versions of bundler installed on your system, then every time you do a bundle installor bundle update(for an app that will be deployed to heroku anyway), you could do it as:

要使用捆绑1.11.2,即使你想拥有更高版本安装在系统上捆绑的,那么你做的每一次bundle installbundle update(用于将反正部署到Heroku上的应用程序),你可以做到这一点的:

 bundle _1.11.2_ install

etc. That will tell rubygems to run the bundle install command with bundler version 1.11.2, and then that version will be recorded in the Gemfile.lock, and you won't get the warning.

等等。这将告诉 ruby​​gems 使用 bundler version 运行 bundle install 命令1.11.2,然后该版本将记录在 中Gemfile.lock,您将不会收到警告。

This is all a bit of a mess. Many developers probably just ignore the warning. It should normally be fine.

这一切都有些混乱。许多开发人员可能只是忽略了警告。正常应该没问题。