質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby on Rails 7

Ruby on Rails 7は、2021年12月に正式リリースされました。Ruby on Railsのバージョン7であり、フロントエンド開発環境を大幅に刷新。Node.jsを用いない構成がデフォルトになっています。

Q&A

1回答

1042閲覧

rails sを実行するとエラーがでてしまう

hqrse0414

総合スコア0

Ruby on Rails 7

Ruby on Rails 7は、2021年12月に正式リリースされました。Ruby on Railsのバージョン7であり、フロントエンド開発環境を大幅に刷新。Node.jsを用いない構成がデフォルトになっています。

0グッド

1クリップ

投稿2022/08/03 05:45

前提

Railsにて"TZInfo::DataSourceNotFound"でエラーが出てしまい、rails serverが起動できません。

実現したいこと

初めてRailsにてWebアプリを作ろうとしたのですが、以下のようにエラーとなってしまい、rails server起動の段階で躓いてしまいました。

アプリは"rails new アプリ名 -G"というコマンドをcmdにて打って作成しました。

rails sを実行しようとすると以下のエラーが出ます。

発生している問題・エラーメッセージ

=> Booting Puma => Rails 7.0.3.1 application starting in development => Run `bin/rails server --help` for more startup options Exiting C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/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:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:156:in `create_default_data_source' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:55:in `block in get' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:54:in `synchronize' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:54:in `get' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/railtie.rb:88:in `block in <class:Railtie>' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:32:in `instance_exec' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:32:in `run' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:61:in `block in run_initializers' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `call' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:60:in `run_initializers' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/application.rb:372:in `initialize!' from C:/Users/souta/sample_app/config/environment.rb:5:in `<main>' from config.ru:3:in `require_relative' from config.ru:3:in `block in <main>' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:116:in `eval' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:116:in `new_from_string' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:105:in `load_file' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:66:in `parse_file' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:349:in `build_app_and_options_from_config' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:249:in `app' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:422:in `wrapped_app' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:36:in `start' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:143:in `block in perform' from <internal:kernel>:90:in `tap' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:134:in `perform' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/command/base.rb:87:in `perform' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/command.rb:48:in `invoke' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands.rb:18:in `<main>' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from bin/rails:4:in `<main>' C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_sources/zoneinfo_data_source.rb:256:in `initialize': None of the paths included in TZInfo::DataSources::ZoneinfoDataSource.search_path are valid zoneinfo directories. (TZInfo::DataSources::ZoneinfoDirectoryNotFound) from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:157:in `new' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:157:in `create_default_data_source' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:55:in `block in get' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:54:in `synchronize' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tzinfo-2.0.5/lib/tzinfo/data_source.rb:54:in `get' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/railtie.rb:88:in `block in <class:Railtie>' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:32:in `instance_exec' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:32:in `run' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:61:in `block in run_initializers' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `call' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each' from C:/Ruby31-x64/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/initializable.rb:60:in `run_initializers' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/application.rb:372:in `initialize!' from C:/Users/souta/sample_app/config/environment.rb:5:in `<main>' from config.ru:3:in `require_relative' from config.ru:3:in `block in <main>' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:116:in `eval' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:116:in `new_from_string' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:105:in `load_file' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/builder.rb:66:in `parse_file' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:349:in `build_app_and_options_from_config' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:249:in `app' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rack-2.2.4/lib/rack/server.rb:422:in `wrapped_app' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:36:in `start' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:143:in `block in perform' from <internal:kernel>:90:in `tap' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands/server/server_command.rb:134:in `perform' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/command/base.rb:87:in `perform' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/command.rb:48:in `invoke' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/railties-7.0.3.1/lib/rails/commands.rb:18:in `<main>' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require' from bin/rails:4:in `<main>'

試したこと

・bundle install
・bundle update
・Gemfileのgem "tzinfo-data",…の行を削除→bundle install
環境はwindows10です。かれこれ色々なサイトを探して試したのですが、ダメでした

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

試したこと

・Gemfileのgem "tzinfo-data",…の行を削除

とありますが、Windows環境でそれをすると逆に悪化するのではと思います。
下記2つの方法を試してみてください。

【案1】

Gemfile に

Gemfile

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

を追加して以下のコマンドを実行

bundle install bundle exec rails server

【案2】

Gemfile を以下のように編集して、

Gemfile

1gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] 23gem "tzinfo-data"

以下のコマンドを実行

bundle install bundle exec rails server

投稿2022/08/22 00:04

shinoharat

総合スコア1676

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問