- 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以及安装最新的版本。(在不同的机器上运行不同版本会导致测试的失败……)你不需要直接地更改Gemfile.lock.
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.