了解Gemfile.lock文件 [英] Understanding the Gemfile.lock file
问题描述
运行bundle install
命令后,在工作目录中创建'Gemfile.lock '.该文件中的指令是什么意思?
After running the bundle install
command, 'Gemfile.lock' is created in the working directory. What do the directives inside that file mean?
例如,让我们获取以下文件:
For example, let's take the following file:
PATH
remote: .
specs:
gem_one (0.0.1)
GEM
remote: http://example.org/
specs:
gem_two (0.0.2)
gem_three (0.0.3)
gem_four (0.0.4)
PLATFORMS
platform
DEPENDENCIES
gem_two
gem_one!
" PATH "," GEM "," PLATFORMS "和"依赖项"分别描述什么?全部都需要吗?
What do 'PATH', 'GEM', 'PLATFORMS' and 'DEPENDENCIES' describe? Are all of them required?
应包含"远程"和"规格"子伪指令?
What should contain the 'remote' and 'specs' subdirectives?
" DEPENDENCIES "组中宝石名称后面的感叹号是什么意思?
What does the exclamation mark after the gem name in the 'DEPENDENCIES' group mean?
推荐答案
You can find more about it in the bundler website (emphasis added below for your convenience):
开发应用程序一段时间后,将应用程序与Gemfile和 Gemfile.lock 快照一起检入.现在,您的存储库中记录了您上一次使用的所有gem的确切版本,以确保应用程序正常工作.
After developing your application for a while, check in the application together with the Gemfile and Gemfile.lock snapshot. Now, your repository has a record of the exact versions of all of the gems that you used the last time you know for sure that the application worked...
这很重要: Gemfile.lock 使您的应用程序既包含您自己的代码,又包含您上次运行时所运行的第三方代码的单个包,以确保一切正常.在gem文件中指定您依赖的第三方代码的确切版本将无法提供相同的保证,因为gem通常会声明其依赖项的版本范围.
This is important: the Gemfile.lock makes your application a single package of both your own code and the third-party code it ran the last time you know for sure that everything worked. Specifying exact versions of the third-party code you depend on in your Gemfile would not provide the same guarantee, because gems usually declare a range of versions for their dependencies.
这篇关于了解Gemfile.lock文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!