There was an error parsing `Gemfile`: `windows` is not a valid platform

320 Views Asked by At

When deploying a Ruby 3.2.2, Rails 7.1.3 app to dokku I get this error very early in the build process:

   !
   !     [!] There was an error parsing `Gemfile`: `windows` is not a valid platform. The available options are: [:ruby, :ruby_18, :ruby_19, :ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24, :ruby_25, :ruby_26, :mri, :mri_18, :mri_19, :mri_20, :mri_21, :mri_22, :mri_23, :mri_24, :mri_25, :mri_26, :rbx, :truffleruby, :jruby, :jruby_18, :jruby_19, :mswin, :mswin_18, :mswin_19, :mswin_20, :mswin_21, :mswin_22, :mswin_23, :mswin_24, :mswin_25, :mswin_26, :mswin64, :mswin64_19, :mswin64_20, :mswin64_21, :mswin64_22, :mswin64_23, :mswin64_24, :mswin64_25, :mswin64_26, :mingw, :mingw_18, :mingw_19, :mingw_20, :mingw_21, :mingw_22, :mingw_23, :mingw_24, :mingw_25, :mingw_26, :x64_mingw, :x64_mingw_20, :x64_mingw_21, :x64_mingw_22, :x64_mingw_23, :x64_mingw_24, :x64_mingw_25, :x64_mingw_26]. Bundler cannot continue.
   !
   !     #  from /tmp/build/Gemfile:39
   !     #  -------------------------------------------
   !     #  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
   !     >  gem "tzinfo-data", platforms: %i[ windows jruby ]
   !     #
   !     #  -------------------------------------------
2

There are 2 best solutions below

0
bjelli On BEST ANSWER

when using dokku with heroku buildpacks you have a choice of a hand full of buildpacks. as of january 2024 the website lists the following runtime versions available:

  • Ruby 3.0.6, Rubygems: 3.2.33 (Heroku-20 only)
  • Ruby 3.1.4, Rubygems: 3.3.26
  • Ruby 3.2.3, Rubygems: 3.4.19
  • Ruby 3.3.0, Rubygems: 3.5.3

In the question Ruby 3.2.2 was specified. This would lead to Ruby 3.2.3 and Rubygems 3.4.19 being chosen. Rubygems 3.4.19 comes with bundler 2.4.19Release Notes.

The Gemfile shown in the question contains :windows, which is not recognized by Bundler 2.4.19.

The solution is to revert to:

  • bundler <= 2.3.6 because bundler 2.5.0 introduces the breaking change of using :windows instead of :mswin
  • gem <= 3.3.27 because gem 3.5.1 uses bundler 2.5.0 as the default

When you use these version in your development environment you will be able to deploy to dokku with current buildpacks.

0
engineersmnky On

Check your rubygems version on dokku.

The Gemfile is created from a Template, this template includes this line

gem "tzinfo-data", platforms: %i[ <%= bundler_windows_platforms %> jruby ]

Your issue is Here

def bundler_windows_platforms
  Gem.rubygems_version >= Gem::Version.new("3.3.22") ? "windows" : "mswin mswin64 mingw x64_mingw"
end

The error seems to indicate that your local rubygems version is >= 3.3.22 but your rubygems version in dokku is not.

To fix this either:

  • Update the rubygems version in dokku gem update --system (if that is possible); or
  • Switch that line in the Gemfile to: gem "tzinfo-data", platforms: %i[mswin mswin64 mingw x64_mingw jruby ] (Note: you will have to update the line for gem "debug" as well if your dokku deployment is running in development or test environment)