Rails server failed because tzinfo-data is not found

140 Views Asked by At

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.

image 1

image 2

Millions of thanks if someone can solve my problem.

1

There are 1 best solutions below

1
On

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 your Gemfile (or any platforms option), Bundler will exclude tzinfo-data from the bundle and you'll get the TZInfo::DataSourceNotFound error.

The solution is to remove the platforms option from the tzinfo-data line in the Gemfile and then run bundle install:

gem 'tzinfo-data'