Ruby on Rails中的Gemfile和Gemfile.lock有什么区别 [英] What is the difference between Gemfile and Gemfile.lock in Ruby on Rails
问题描述
我是Ruby on Rails的初学者,并且正在使用Rails 3.0.9.
I am a beginner to Ruby on Rails and I am using Rails 3.0.9.
Rails中的Gemfile
和Gemfile.lock
有什么区别?
What is the difference between Gemfile
and Gemfile.lock
in Rails?
推荐答案
Gemfile
是您在其中指定要使用的gem的地方,并可以指定哪些版本.
The Gemfile
is where you specify which gems you want to use, and lets you specify which versions.
Gemfile.lock
文件是Bundler记录已安装的确切版本的位置.这样,当同一库/项目加载到另一台计算机上时,运行bundle install
将查看Gemfile.lock
并安装完全相同的版本,而不是仅使用Gemfile
并安装最新版本. (在不同的计算机上运行不同的版本可能会导致测试失败等.)您永远不必直接编辑锁定文件.
The Gemfile.lock
file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install
will look at the Gemfile.lock
and install the exact same versions, rather than just using the Gemfile
and installing the most recent versions. (Running different versions on different machines could lead to broken tests, etc.) You shouldn't ever have to directly edit the lock file.
查看捆绑商的目的和原理,特别是将代码检入版本控制"部分
Check out Bundler's Purpose and Rationale, specifically the Checking Your Code into Version Control section.
这篇关于Ruby on Rails中的Gemfile和Gemfile.lock有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!