我已经在我的gemfile上添加了gem"tzinfo data",但它一直在说,请在我制作rails服务器时添加tzinfo数据。
是因为我安装了rails还是安装了ruby,或者我缺少了一些步骤?
C:UsersLENOVO 330S-15ARRsample_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>'
错误导致的图片
我该如何解决这个错误?
Bundler中有一个错误,这意味着没有有效的平台值可以与Windows上的64位Ruby 3.1相匹配。
如果Gemfile
中的gem 'tzinfo-data
行包含platforms
选项,Bundler将从捆绑包中排除tzinfo数据,您将得到TZInfo::DataSourceNotFound
错误。
解决方案是从Gemfile中的tzinfo数据行中删除platforms
选项,然后运行bundle install
:
gem 'tzinfo-data'
确保gemfile包含gem "
tzinfo数据"然后进行捆绑安装。
只需确保gem是独立于平台的