How to solve tzinfo error on ruby on rails?

2.4k Views Asked by At

Trying to learn ruby on rails and I keep coming up with this error:

rails aborted!
TZInfo::DataSourceNotFound: tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install
Caused by:
TZInfo::DataSources::ZoneinfoDirectoryNotFound: None of the paths included in TZInfo::DataSources::ZoneinfoDataSource.search_path are valid zoneinfo directories.
D:/RubyRails/ineedhelp/config/environment.rb:5:in `<main>'
Tasks: TOP => app:template => environment
(See full trace by running task with --trace)
       rails  turbo:install stimulus:install
You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem.
You must either be running with node (package.json) or importmap-rails (config/importmap.rb) to use this gem.

when I'm starting a new project

I'm using Windows 10 64bit.

Though I keep adding gem "tzinfo-data" to my application's GemFile AND use gem install tzinfo in cmd, it doesn't work. It may work temporarily but the error keeps showing up each time I'm trying to insert another command in cmd (like rails s).

gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

This line is already in my GemFile when the error pops up. I already tried several solutions found online.

2

There are 2 best solutions below

0
On

Just remove the platform part This is how your gem name should look like

 gem "tzinfo-data"
0
On

you can install tzdata package on Debian

apt install tzdata