无法构建 rails 服务器 tzinfo 的原因
failed to build rails server cause of tzinfo
我已经在我的 gem 文件中添加了 gem 'tzinfo-data',但它一直说在我创建 rails 服务器时请添加 tzinfo-data。
是因为我安装了rails还是安装了ruby,还是我漏掉了一些步骤?
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
如何解决这个错误?
bug in Bundler 表示 Windows 上没有匹配 64 位 Ruby 3.1 的有效平台值。
如果 Gemfile
中的 gem 'tzinfo-data
行包含 platforms
选项,Bundler 将从包中排除 tzinfo-data,您将获得 TZInfo::DataSourceNotFound
错误。
解决办法是把Gemfile中tzinfo-data行的platforms
选项去掉,然后运行 bundle install
:
gem 'tzinfo-data'
确保gem文件包含gem "
tzinfo-data”,然后进行捆绑安装。
只需确保 gem 与平台无关
我已经在我的 gem 文件中添加了 gem 'tzinfo-data',但它一直说在我创建 rails 服务器时请添加 tzinfo-data。
是因为我安装了rails还是安装了ruby,还是我漏掉了一些步骤?
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
如何解决这个错误?
bug in Bundler 表示 Windows 上没有匹配 64 位 Ruby 3.1 的有效平台值。
如果 Gemfile
中的 gem 'tzinfo-data
行包含 platforms
选项,Bundler 将从包中排除 tzinfo-data,您将获得 TZInfo::DataSourceNotFound
错误。
解决办法是把Gemfile中tzinfo-data行的platforms
选项去掉,然后运行 bundle install
:
gem 'tzinfo-data'
确保gem文件包含gem "
tzinfo-data”,然后进行捆绑安装。
只需确保 gem 与平台无关