运行 捆绑包或 rspec 添加行到 Gemfile.lock
Running bundle or rspec adds line to Gemfile.lock
在 Ruby 项目中 运行 各种命令(例如 bundle 和 rspec)之后,Gemfile.lock
被更新并且 x86_64-darwin-17
添加到PLATFORMS
标题。为什么会这样?我该如何预防?
运行 gem env
给出了这个有趣的上下文:
○ → gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin17]
#...etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
如果您想在不更新 Gemfile.lock
的情况下安装依赖项,只需使用 --frozen
option。例如bundle --frozen
。这将正常安装依赖项,除了不更新 Gemfile.lock
编辑
如果这不是一个好的解决方案,最好的办法可能是将 Gemfile.lock
添加到特定于您本地存储库的 .gitignore
中。
您可以根据 this answer
在 your_repo/.git/info/exclude
创建一个
这是由全局捆绑器配置引起的。设置为 false 会停止该行为。
specific_platform (BUNDLE_SPECIFIC_PLATFORM): Allow bundler to resolve for the specific running platform and store it in the lockfile, instead of only using a generic platform. A specific platform is the exact platform triple reported by Gem::Platform.local, such as x86_64-darwin-16 or universal-java-1.8. On the other hand, generic platforms are those such as ruby, mswin, or java. In this example, x86_64-darwin-16 would map to ruby and universal-java-1.8 to java.
@RangerRanger 的回答对我不起作用,但我像他一样检查了 bundler doc 并找到了为我工作的人:
force_ruby_platform (BUNDLE_FORCE_RUBY_PLATFORM): Ignore the current machine's platform and install only ruby platform gems. As a result, gems with native extensions will be compiled from source.
命令如下:bundle config force_ruby_platform true
在 Ruby 项目中 运行 各种命令(例如 bundle 和 rspec)之后,Gemfile.lock
被更新并且 x86_64-darwin-17
添加到PLATFORMS
标题。为什么会这样?我该如何预防?
运行 gem env
给出了这个有趣的上下文:
○ → gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.6
- RUBY VERSION: 2.5.1 (2018-03-29 patchlevel 57) [x86_64-darwin17]
#...etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
如果您想在不更新 Gemfile.lock
的情况下安装依赖项,只需使用 --frozen
option。例如bundle --frozen
。这将正常安装依赖项,除了不更新 Gemfile.lock
编辑
如果这不是一个好的解决方案,最好的办法可能是将 Gemfile.lock
添加到特定于您本地存储库的 .gitignore
中。
您可以根据 this answer
your_repo/.git/info/exclude
创建一个
这是由全局捆绑器配置引起的。设置为 false 会停止该行为。
specific_platform (BUNDLE_SPECIFIC_PLATFORM): Allow bundler to resolve for the specific running platform and store it in the lockfile, instead of only using a generic platform. A specific platform is the exact platform triple reported by Gem::Platform.local, such as x86_64-darwin-16 or universal-java-1.8. On the other hand, generic platforms are those such as ruby, mswin, or java. In this example, x86_64-darwin-16 would map to ruby and universal-java-1.8 to java.
@RangerRanger 的回答对我不起作用,但我像他一样检查了 bundler doc 并找到了为我工作的人:
force_ruby_platform (BUNDLE_FORCE_RUBY_PLATFORM): Ignore the current machine's platform and install only ruby platform gems. As a result, gems with native extensions will be compiled from source.
命令如下:bundle config force_ruby_platform true