直接修改 Gemfile.lock 会发生什么? [英] What happens when modifying Gemfile.lock directly?

查看:23
本文介绍了直接修改 Gemfile.lock 会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从 bundle install 第二次执行后,只要 Gemfile 没有改变,依赖项就会从 Gemfile.lock 加载.

Since the second time of bundle install execution, dependencies are loaded from Gemfile.lock as long as Gemfile isn't changed.

但我想知道如何检测这两个文件之间的更改.

But I wonder how detection of changes is made between those two files.

例如,如果我将新依赖项直接添加到 Gemfile.lock 中而不将其添加到 Gemfile 中(与最佳实践相反,因为 Gemfile.lock 是从 Gemfile 自动生成的),bundle 是否会安装 认为 Gemfile 已更改?

For instance, if I'm adding a new dependency directly into Gemfile.lock without adding it into Gemfile (as opposed to the best practice since Gemfile.lock is auto-generated from Gemfile), would a bundle install consider Gemfile as changed ?

确实,bundle install 进程是否会比较整个 Gemfile 和 Gemfile.lock 树以检测更改?

Indeed, does bundle install process compares the whole Gemfile and Gemfile.lock trees in order to detect changes?

如果是这样,即使我直接将依赖项添加到 Gemfile.lock,Gemfile 也会被检测为已更改(因为不同)并会重新擦除 Gemfile.lock(因此丢失添加的依赖项...)

If it is, even if I'm adding a dependency directly to Gemfile.lock, Gemfile would be detected as changed (since different) and would re-erase Gemfile.lock (so losing the added dependency...)

bundle install第二次上线后的流程是怎样的?

What is the process of bundle install since the launch for the second time ?

为了更清楚,我的问题是:

To be more clear, my question is:

是否仅基于 Gemfile 的更改?这意味着捆绑器将保留每个 bundle install 执行次数 N 的 Gemfile 快照,并将其与 bundle install 执行 N+1 进行比较?

Are changes based only from Gemfile ? That means bundler would keep a Gemfile snapshot of every bundle install execution number N and merely compares it to the bundle install execution N+1 ?

或者在 bundler 内存中没有创建快照,并且 bundler 每次都与 Gemfile.lock 进行比较,以检测是否必须将 Gemfile 视为已更改.

Or no snapshots are created in bundler memory and bundler makes a comparison with Gemfile.lock each time to detect if Gemfile must be considered as changed.

推荐答案

如果你编辑你的 Gemfile.lock 那么 Rails 应用程序将依赖于其他版本的 gems... 你的 gem-versioning 系统的完整性会被破坏案件.直接编辑 Gemfile.lock 文件是一个非常非常糟糕的主意.

If you edit your Gemfile.lock then Rails app would depend on another versions of gems... The integrity of your gem-versioning system would be broken in this case. It's a very-very bad idea to edit Gemfile.lock file directly.

请做个好人,只与 Gemfile 做交易

Please, be a good guy and make deals with Gemfile only

这篇关于直接修改 Gemfile.lock 会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆