Gemfile 中 gem 的 'platforms' 参数到底是什么?
What exactly is the 'platforms' argument for gem in Gemfile?
从基础开始,我在 Gemfile 中看到了这样的东西
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
此代码是否告诉 Gemfile:“如果平台是以下之一,则仅安装 tzinfo-data gem:mingw、mswin、x64_mingw、jruby;如果是任何其他操作系统,不要安装它"?
背景:对此感兴趣的原因是因为我在 运行 bundle install
时收到警告,我只想在开始修补它之前了解它是如何工作的。
另请注意:我在 https://api.rubyonrails.org/ 中搜索了 'gem'、'group' 和 'platforms',但我找不到相关解释。
Also note: I searched https://api.rubyonrails.org/ for 'gem', 'group', and 'platforms' but I couldn't spot an explanation there.
有道理,Gemfiles 不是 Rails 的一部分。它们由 Bundler.
提供
Is this code telling the Gemfile: "only install tzinfo-data gem if the platform is one of these: mingw, mswin, x64_mingw, jruby; if it's any other operating system, don't install it"?
是的,没错。您可以在 Platform section of the Gemfile docs.
中了解它们的确切含义
特别是tzinfo
gem needs an up-to-date time zone databases. It will use the one installed on the operating system. If the operating system doesn't provide one, or if it doesn't keep it up to date, you can install the tzinfo-data
gem。大多数 non-Windows 机器维护自己的时区数据库。
从基础开始,我在 Gemfile 中看到了这样的东西
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
此代码是否告诉 Gemfile:“如果平台是以下之一,则仅安装 tzinfo-data gem:mingw、mswin、x64_mingw、jruby;如果是任何其他操作系统,不要安装它"?
背景:对此感兴趣的原因是因为我在 运行 bundle install
时收到警告,我只想在开始修补它之前了解它是如何工作的。
另请注意:我在 https://api.rubyonrails.org/ 中搜索了 'gem'、'group' 和 'platforms',但我找不到相关解释。
Also note: I searched https://api.rubyonrails.org/ for 'gem', 'group', and 'platforms' but I couldn't spot an explanation there.
有道理,Gemfiles 不是 Rails 的一部分。它们由 Bundler.
提供Is this code telling the Gemfile: "only install tzinfo-data gem if the platform is one of these: mingw, mswin, x64_mingw, jruby; if it's any other operating system, don't install it"?
是的,没错。您可以在 Platform section of the Gemfile docs.
中了解它们的确切含义特别是tzinfo
gem needs an up-to-date time zone databases. It will use the one installed on the operating system. If the operating system doesn't provide one, or if it doesn't keep it up to date, you can install the tzinfo-data
gem。大多数 non-Windows 机器维护自己的时区数据库。