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

exdqitrt  于 2023-05-02  发布在  Ruby
关注(0)|答案(2)|浏览(182)

尝试学习ruby on rails,我一直遇到这个错误:

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 64bit。
尽管我不断地将gem "tzinfo-data"添加到应用程序的GemFile中,并在cmd中使用gem install tzinfo,但它不起作用。它可能会暂时工作,但每次我试图在cmd中插入另一个命令(如rails s)时,错误都会出现。

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

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

ifmq2ha2

ifmq2ha21#

只需删除平台部分这就是您的gem名称的样子

gem "tzinfo-data"
yptwkmov

yptwkmov2#

您可以在Debian上安装tzdata软件包

apt install tzdata

相关问题