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

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

问题描述

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



但是我想知道如何检测这两个文件之间的变化。例如,如果我将新的依赖关系直接添加到Gemfile中。锁而不将它添加到Gemfile中(而不是从Gemfile自动生成Gemfile.lock的最佳实践), bundle install 会认为Gemfile已更改?



的确, bundle install 进程会比较整个Gemfile和Gemfile.lock树以检测更改吗?如果是这样,即使我直接向Gemfile.lock添加依赖项,Gemfile也会被检测为已更改(因为不同),并会重新擦除Gemfile。锁(因此失去了添加的依赖...)



自启动以来, bundle install 第二次?

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

只是基于Gemfile的更改?这意味着bundler会保留每个 bundle install 执行次数N的Gemfile快照,并仅将它与 bundle install 执行进行比较N + 1?



或者在捆绑器内存中未创建快照,并且捆绑器每次都会与Gemfile.lock进行比较,以检测是否必须将Gemfile视为已更改。如果你编辑你的Gemfile.lock,那么Rails应用程序将依赖于其他版本的gems ...你的gem版本的完整性系统将在这种情况下被打破。直接编辑Gemfile.lock文件是一个非常糟糕的主意。



请成为一名好人并仅与Gemfile进行交易

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.

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 ?

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

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

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

To be more clear, my question is:

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 ?

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.

解决方案

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.

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

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

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