ruby-on-railstzinfo

failed to build rails server cause of tzinfo


i already add gem 'tzinfo-data' on my gemfile but its keep saying please add tzinfo-data when I make rails server.

Is it because of the rails that I install or ruby that I install, or maybe there is some step that I missing?

C:\Users\LENOVO 330S-15ARR\sample_app>rails s
=> Booting Puma
=> Rails 7.0.2.3 application starting in development
=> Run `bin/rails server --help` for more startup options
Exiting
C:/Ruby/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:159:in `rescue in create_default_data_source': tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install (TZInfo::DataSourceNotFound)
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:156:in `create_default_data_source'        from C:/Ruby/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:55:in `block in get'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:54:in `synchronize'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.4/lib/tzinfo/data_source.rb:54:in `get'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/activesupport-7.0.2.3/lib/active_support/railtie.rb:88:in `block in <class:Railtie>'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/lib/rails/initializable.rb:32:in `instance_exec'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/lib/rails/initializable.rb:32:in `run'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:347:in `each'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:347:in `call'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
        from C:/Ruby/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/lib/rails/initializable.rb:60:in `run_initializers'
        from C:/Ruby/lib/ruby/gems/3.1.0/gems/railties-7.0.2.3/lib/rails/application.rb:372:in `initialize!'
        from C:/Users/LENOVO 330S-15ARR/sample_app/config/environment.rb:5:in `<main>'
        from config.ru:3:in `require_relative'
        from config.ru:3:in `block in <main>'

the picture of error cause

how can I solve this error?


Solution

  • There's a bug in Bundler that means there's no valid platform value that will match 64-bit Ruby 3.1 on Windows.

    If the gem 'tzinfo-data line in your Gemfile includes a 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'