I'm using Ruby 3.1.2 on Windows(x64) and I'm trying to run rails server and connect to localhost:3000.
I execute rails s
in cmd (while directing to the folder created by rails new
), but the message shows tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install (TZInfo::DataSourceNotFound)
Then, I open the Gemfile in .txt and write this line: gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
I also do bundle install
after that.
But when I do rails server
again, it still shows the same message saying that tzinfo-data is not present.
Millions of thanks if someone can solve my problem.
There's a bug in Bundler that means there's no valid platform value that will match 64-bit Ruby 3.1 on Windows.
With
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
in yourGemfile
(or anyplatforms
option), Bundler will exclude tzinfo-data from the bundle and you'll get theTZInfo::DataSourceNotFound
error.The solution is to remove the
platforms
option from the tzinfo-data line in the Gemfile and then runbundle install
: