TZInfo::DataSourceNotFound: No timezone data source could be found

Recently I’ve installed Ruby and Rails on Windows x64, but I had some kind of strange error:

TZInfo::DataSourceNotFound: No timezone data source could be found

If you go to your rails app Gemfile, you can notice those two lines:

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

Rails is trying to install tzinfo-data gem for Windows, but it still fails to start with rails server command. Why?

The reason is that I used Windows x64 version of Ruby Installer. And the correct symbol for this version of Ruby is :x64_mingw. Currently in Rails there are still no support for Windows x64 systems. All you have to do is just add this symbol to your Gemfile:

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

Now just run bundle update and you’re done. Now your rails app works on Windows x64! Happy coding!

Advertisements