To start with basics, I see things like this in the Gemfile
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
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"?
Background: The reason for the interest in this is because I get a warning when running bundle install
and I just want to understand how it all works before I start tinkering with it.
Also note: I searched https://api.rubyonrails.org/ for 'gem', 'group', and 'platforms' but I couldn't spot an explanation there.
CodePudding user response:
Also note: I searched https://api.rubyonrails.org/ for 'gem', 'group', and 'platforms' but I couldn't spot an explanation there.
Makes sense, Gemfiles aren't part of Rails. They are provided by 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"?
Yes, exactly. You can read about their exact meanings in the Platform section of the Gemfile docs.
In particular, the 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. Most non-Windows machines maintain their own time zone database.