Ruby-on-rails 如何在更改 Gemfile 时重新同步 Gemfile.lock

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13101945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 20:55:56  来源:igfitidea点击:

How to re-sync Gemfile.lock on changes to Gemfile

ruby-on-railsrvmbundler

提问by Joe

How to re-sync Gemfile.lock on changes to Gemfile.

如何在更改 Gemfile 时重新同步 Gemfile.lock。

Assuming I have 3 gems (gem1, gem2, gem3) in the Gemfile.

假设我在 Gemfile 中有 3 个宝石(gem1、gem2、gem3)。

bundle installcreates a Gemfile.lock file.

bundle install创建一个 Gemfile.lock 文件。

If I remove gem3 and run bundle install, I would like Gemfile.lock to be re-generated and gem3 removed from the rvm gemset. But it doesn't, how should I re-sync without dropping the gemset.

如果我删除 gem3 并运行bundle install,我希望重新生成 Gemfile.lock 并从 rvm gemset 中删除 gem3。但事实并非如此,我应该如何在不丢弃 gemset 的情况下重新同步。

回答by Prakash Murthy

To bring the Gemfile.lock in line with Gemfile edits, run bundle check.

要使 Gemfile.lock 与 Gemfile 编辑一致,请运行bundle check.

To bring the Gemfile.lock in line with both the Gemfile edits AND the latest compatible gems, run bundle update.

要使 Gemfile.lock 与 Gemfile 编辑和最新兼容的 gem 一致,请运行bundle update.



Related: This blogpost by viget has some good advice on Bundler Best Practices

相关:viget 的这篇博文对Bundler 最佳实践有一些很好的建议