如何解决ruby on rails上的tzinfo错误



试图在rails上学习ruby时,我一直遇到这个错误:

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.

当我开始一个新项目

我使用的是Windows 10 64位。

尽管我一直在应用程序的GemFile中添加gem "tzinfo-data",并在cmd中使用gem install tzinfo,但它不起作用。它可能暂时有效,但每次我试图在cmd中插入另一个命令(如rails s(时,错误都会不断出现。

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

当错误弹出时,这一行已经在我的GemFile中了。我已经尝试了网上找到的几种解决方案。

只需移除平台部分这就是你的宝石名称应该看起来像的样子

gem "tzinfo-data"

您可以在Debian 上安装tzdata

apt install tzdata

最新更新