Techioz Blog

Heroku アプリを開こうとするとクラッシュする

概要

Heroku から [アプリを開く] をクリックすると、次のメッセージが表示される画面が表示されます。

ターミナルでこのコマンドを実行すると、次の結果が得られます。

2023-05-02T20:55:46.008048+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=stark-brushlands-01940.herokuapp.com request_id=089a1f69-2776-42f8-96fe-6483816d7db6 fwd="76.100.146.70" dyno= connect= service= status=503 bytes= protocol=https
2023-05-02T20:55:46.296015+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=stark-brushlands-01940.herokuapp.com request_id=7eedd68b-4683-4ab5-ae47-35f00fb6b958 fwd="76.100.146.70" dyno= connect= service= status=503 bytes= protocol=https

スタック トレースの詳細を次に示します。

2023-05-02T21:46:58.098960+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=stark-brushlands-01940.herokuapp.com request_id=a0d2bfa4-b583-4cd4-91d8-aa4524886c18 fwd="76.100.146.70" dyno= connect= service= status=503 bytes= protocol=https
2023-05-02T21:46:58.380588+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=stark-brushlands-01940.herokuapp.com request_id=4badb527-3741-4426-9bee-c6ca4d8fd3f2 fwd="76.100.146.70" dyno= connect= service= status=503 bytes= protocol=https
2023-05-02T21:47:14.133483+00:00 heroku[web.1]: State changed from crashed to starting
2023-05-02T21:47:22.910963+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production`
2023-05-02T21:47:25.776952+00:00 app[web.1]: => Booting Puma
2023-05-02T21:47:25.776974+00:00 app[web.1]: => Rails 6.1.4.6 application starting in production
2023-05-02T21:47:25.776974+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options
2023-05-02T21:47:25.777930+00:00 app[web.1]: Exiting
2023-05-02T21:47:25.778017+00:00 app[web.1]: /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:17:in `dirname': no implicit conversion of nil into String (TypeError)
2023-05-02T21:47:25.778020+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:17:in `realpath'
2023-05-02T21:47:25.778023+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:7:in `block in initialize'
2023-05-02T21:47:25.778023+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:11:in `call'
2023-05-02T21:47:25.778024+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `require_relative'
2023-05-02T21:47:25.778028+00:00 app[web.1]: from config.ru:3:in `block in <main>'
2023-05-02T21:47:25.778030+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:116:in `eval'
2023-05-02T21:47:25.778032+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:116:in `new_from_string'
2023-05-02T21:47:25.778032+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:105:in `load_file'
2023-05-02T21:47:25.778033+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:66:in `parse_file'
2023-05-02T21:47:25.778033+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:349:in `build_app_and_options_from_config'
2023-05-02T21:47:25.778033+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:249:in `app'
2023-05-02T21:47:25.778034+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:422:in `wrapped_app'
2023-05-02T21:47:25.778034+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:312:in `block in start'
2023-05-02T21:47:25.778034+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:379:in `handle_profiling'
2023-05-02T21:47:25.778034+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:311:in `start'
2023-05-02T21:47:25.778034+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands/server/server_command.rb:39:in `start'
2023-05-02T21:47:25.778034+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands/server/server_command.rb:144:in `block in perform'
2023-05-02T21:47:25.778035+00:00 app[web.1]: from <internal:kernel>:90:in `tap'
2023-05-02T21:47:25.778036+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands/server/server_command.rb:135:in `perform'
2023-05-02T21:47:25.778044+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
2023-05-02T21:47:25.778044+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
2023-05-02T21:47:25.778051+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
2023-05-02T21:47:25.778052+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/command/base.rb:69:in `perform'
2023-05-02T21:47:25.778059+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/command.rb:48:in `invoke'
2023-05-02T21:47:25.778059+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands.rb:18:in `<main>'
2023-05-02T21:47:25.778060+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
2023-05-02T21:47:25.778076+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
2023-05-02T21:47:25.778076+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2023-05-02T21:47:25.778077+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2023-05-02T21:47:25.778077+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
2023-05-02T21:47:25.778079+00:00 app[web.1]: from bin/rails:4:in `<main>'
2023-05-02T21:47:26.022304+00:00 heroku[web.1]: Process exited with status 1
2023-05-02T21:47:26.060411+00:00 heroku[web.1]: State changed from starting to crashed
2023-05-02T21:47:26.064963+00:00 heroku[web.1]: State changed from crashed to starting
2023-05-02T21:47:34.265381+00:00 heroku[web.1]: Starting process with command `bin/rails server -p ${PORT:-5000} -e production`
2023-05-02T21:47:35.951605+00:00 app[web.1]: => Booting Puma
2023-05-02T21:47:35.951635+00:00 app[web.1]: => Rails 6.1.4.6 application starting in production
2023-05-02T21:47:35.951635+00:00 app[web.1]: => Run `bin/rails server --help` for more startup options
2023-05-02T21:47:35.952460+00:00 app[web.1]: Exiting
2023-05-02T21:47:35.952519+00:00 app[web.1]: /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:17:in `dirname': no implicit conversion of nil into String (TypeError)
2023-05-02T21:47:35.952522+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:17:in `realpath'
2023-05-02T21:47:35.952524+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:7:in `block in initialize'
2023-05-02T21:47:35.952525+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/realpath_cache.rb:11:in `call'
2023-05-02T21:47:35.952525+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `require_relative'
2023-05-02T21:47:35.952528+00:00 app[web.1]: from config.ru:3:in `block in <main>'
2023-05-02T21:47:35.952530+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:116:in `eval'
2023-05-02T21:47:35.952532+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:116:in `new_from_string'
2023-05-02T21:47:35.952533+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:105:in `load_file'
2023-05-02T21:47:35.952533+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/builder.rb:66:in `parse_file'
2023-05-02T21:47:35.952534+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:349:in `build_app_and_options_from_config'
2023-05-02T21:47:35.952534+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:249:in `app'
2023-05-02T21:47:35.952535+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:422:in `wrapped_app'
2023-05-02T21:47:35.952543+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:312:in `block in start'
2023-05-02T21:47:35.952543+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:379:in `handle_profiling'
2023-05-02T21:47:35.952543+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.7/lib/rack/server.rb:311:in `start'
2023-05-02T21:47:35.952544+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands/server/server_command.rb:39:in `start'
2023-05-02T21:47:35.952544+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands/server/server_command.rb:144:in `block in perform'
2023-05-02T21:47:35.952545+00:00 app[web.1]: from <internal:kernel>:90:in `tap'
2023-05-02T21:47:35.952553+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands/server/server_command.rb:135:in `perform'
2023-05-02T21:47:35.952553+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
2023-05-02T21:47:35.952554+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
2023-05-02T21:47:35.952554+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
2023-05-02T21:47:35.952555+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/command/base.rb:69:in `perform'
2023-05-02T21:47:35.952556+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/command.rb:48:in `invoke'
2023-05-02T21:47:35.952563+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/railties-6.1.4.6/lib/rails/commands.rb:18:in `<main>'
2023-05-02T21:47:35.952563+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
2023-05-02T21:47:35.952565+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
2023-05-02T21:47:35.952565+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
2023-05-02T21:47:35.952566+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
2023-05-02T21:47:35.952567+00:00 app[web.1]: from /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
2023-05-02T21:47:35.952567+00:00 app[web.1]: from bin/rails:4:in `<main>'
2023-05-02T21:47:36.141842+00:00 heroku[web.1]: Process exited with status 1
2023-05-02T21:47:36.218370+00:00 heroku[web.1]: State changed from starting to crashed

Michael Hartl の Ruby on Rails チュートリアルに従っていますが、アプリを問題なく起動して実行できるはずだと示唆されています。アプリがクラッシュする理由がわかりません。

heroku restart コマンドを何度も試し、Gemfile.lock に x86_64-linux をプラットフォームとして追加しました。問題が何なのか、さらにトラブルシューティングを行う方法がわかりません。

Stack Overflow で見つけた他の提案も試しましたが、どれも問題を解決できませんでした。

解決策

これは修正できましたが、何が修正されたのかは 100% わかりません。私は自分の Gemfile を Hartl の Github ページにある最新のものと交換し、Ruby のバージョンを彼の (3.1.2) 実行バンドルの更新に合わせて更新し、更新された Gemfile.lock を Git と Heroku にプッシュし、今では Heroku にプッシュしました。アプリは期待どおりに動作します。