为什么 Heroku 在 Windows 中不接受我的 Gemfile.lock?
我有一个部署在 Heroku 上的 Rails 应用程序。我正在使用几台不同的机器,并且我注意到当我添加新的依赖项(以便重建 Gemfile.lock
)并在家里的 Windows 计算机上执行 bundle install
时,推送到 Heroku 失败并出现以下错误:
Unresolved dependencies detected; Installing...
Windows Gemfile.lock detected, ignoring it.
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
...
Gemfile.lock
处于版本控制之下,但 Heroku 似乎选择忽略它,因为它是在 Windows 中创建的,然后抱怨几秒钟后它丢失了。为什么会出现这种情况?我该如何解决它?
I have a rails application that I deploy on Heroku. I'm using several different machines, and I noticed that when I add new dependencies (so that Gemfile.lock
is rebuilt) and do bundle install
on my Windows computer at home, push to Heroku fails with the following error:
Unresolved dependencies detected; Installing...
Windows Gemfile.lock detected, ignoring it.
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
...
Gemfile.lock
IS under version control, but Heroku appearently chooses to ignore it since it's created in Windows, and then complains that it's missing seconds later. Why does this happen? And how can I solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我通过打开 Gemfile.lock 并删除以下两行来修复我的问题:
所以现在我只需要制作一个脚本来捆绑然后从锁定文件中删除它。
I fixed mine by opening Gemfile.lock and deleting the following two lines:
So now i just need to make a script that bundles then removes that from the lock file.
就像上面评论的 matt 一样:
问题是 Bundler 为 Windows 创建了不同的 Gemfile.lock。唯一的解决方案是在 *NIX 系统上创建并提交锁定文件。
我建议创建一个运行例如 Ubuntu 的虚拟机 - 可能使用 Virtual Box 。您甚至可以获得现成的虚拟机 - 例如此处。
Like matt commented above:
The problem is that Bundler creates different
Gemfile.lock
s for Windows. The only solution is to create and commit the lock file on a *NIX system.I would suggest to create a virtual machine running e.g. Ubuntu – maybe using Virtual Box. You can even get ready-to-use virtual machines – for example here.
来自 Heroku 文档:
From the Heroku Docs:
刚刚与这个问题斗争了一段时间。
我将 gemfile 修剪回 Rails,但问题仍然存在。然后,想到今天 Heroku 要求更新 heroku gem,我仔细研究了 heroku 的变化。
看来 1.9.2 ruby“bamboo”堆栈现在是默认堆栈 - 我的应用程序仍在 1.8.7 堆栈上运行。所以我运行了“heroku stack:migrateamboa-mri-1.9.2”并将堆栈更新到1.9.2 - 这不是我想做的事情,但你知道吗,它解决了上面的问题。
当然,我不想使用 1.9.2 堆栈,因此我迁移回 1.8.7 堆栈,并且再次正确安装。所以我认为这是一种解决方法 - 可能是一个过于复杂的方法 - 但它似乎“刷新”了 Heroku 端的任何错误。由于我在本地所做的任何事情(并且我尝试了 StackOverflow 文章中的很多内容)都没有任何效果,因此推送一直失败,如上所述。
所以是的,这解决了它。也不需要太长时间。但怀疑更多了解 Heroku 的开发人员可能会发现更好的解决方法!
Just battled through this problem for a while.
I trimmed my gemfile back to just rails and still had the issue. Then, thinking that heroku had demanded an update of the heroku gem today, I looked closer at heroku changes.
It seems the 1.9.2 ruby "bamboo" stack is now the default one - my app is still running on the 1.8.7 stack. So I ran "heroku stack:migrate bamboo-mri-1.9.2" and updated the stack to 1.9.2 - not something I wanted to do, but you know what, it fixed the issue above.
Of course, I didn't want to be on the 1.9.2 stack, so I migrated back down to the 1.8.7 stack, and things installed correctly again. So I think this is a workaround - and probably an overly complex one - but it seemed to "flush" whatever the error was heroku-side. As nothing I did locally (and I tried a LOT of things from StackOverflow articles) had any effect, the push just kept failing as above.
So yeah, this fixes it. Doesn't take too long either. But suspect a better workaround may be spotted by more heroku-knowledgeable developers !
确保在安装捆绑包后提交对
Gemfile.lock
的更改。在您下次push
到 Heroku 时,新的 gems 应该会正确安装。Make sure you commit the changes to
Gemfile.lock
after installing the bundle. On your nextpush
to Heroku, the new gems should be installed correctly.