迷い人

日々勉強。勉強の先に何か見つかるといいなぁ

【回答】エラー対処について

 

 

 

 

問題

「  $ git push heroku 」を実行した際、以下のエラーが発生した。

エラー原因を調べる時、ヒントとなる情報がある部分はどこでしょうか。

 

前提

railsチュートリアル11章で発生したエラーです。

 

 

エラーログ

Enumerating objects: 46, done.
Counting objects: 100% (35/35), done.
Delta compression using up to 4 threads
Compressing objects: 100% (16/16), done.
Writing objects: 100% (16/16), 3.51 KiB | 3.51 MiB/s, done.
Total 16 (delta 9), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: 
remote: ###### WARNING:
remote: 
remote:        This buildpack was created as a stop-gap measure to allow running applications with Bundler 2 on Heroku.
remote:        Heroku now supports Bundler 2 directly: https://devcenter.heroku.com/changelog-items/1563
remote:        
remote:        Please discontinue use of this buildpack and instead directly use the `heroku/ruby` buildpack.
remote:        
remote:        To remove this buildpack use the `heroku buildpacks` command to list your existing buildpacks.
remote:        
remote:        If you only have one buildpack listed you can run:
remote:        
remote:        ```
remote:        heroku buildpacks:set heroku/ruby
remote:        ```
remote:        
remote:        If you have multiple buildpacks, you'll need to add the buildpack to the correct location using
remote:        `heroku buildpacks:add heroku/ruby -i <correct index>` and then remove this buildpack via:
remote:        
remote:        ```
remote:        heroku buildpacks:remove https://github.com/bundler/heroku-buildpack-bundler2
remote:        ```
remote: 
remote:        Your app was upgraded to bundler 2.0.1.
remote:        Previously you had a successful deploy with bundler 2.0.2.
remote:        
remote:        If you see problems related to the bundler version please refer to:
remote:        https://devcenter.heroku.com/articles/bundler-version
remote:        
remote: -----> Using Ruby version: ruby-2.5.1
remote: -----> Installing dependencies using bundler 2.0.1
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
remote:        Using rake 13.0.1
remote:        Using concurrent-ruby 1.1.5
remote:        Using i18n 1.7.0
remote:        Using minitest 5.13.0
remote:        Using thread_safe 0.3.6
remote:        Using tzinfo 1.2.5
remote:        Using activesupport 5.2.3
remote:        Using builder 3.2.3
remote:        Using erubi 1.9.0
remote:        Using mini_portile2 2.4.0
remote:        Using nokogiri 1.10.5
remote:        Using rails-dom-testing 2.0.3
remote:        Using crass 1.0.5
remote:        Using loofah 2.3.1
remote:        Using rails-html-sanitizer 1.3.0
remote:        Using actionview 5.2.3
remote:        Using rack 2.0.7
remote:        Using rack-test 1.1.0
remote:        Using actionpack 5.2.3
remote:        Using nio4r 2.5.2
remote:        Using websocket-extensions 0.1.4
remote:        Using websocket-driver 0.7.1
remote:        Using actioncable 5.2.3
remote:        Using globalid 0.4.2
remote:        Using activejob 5.2.3
remote:        Using mini_mime 1.0.2
remote:        Using mail 2.7.1
remote:        Using actionmailer 5.2.3
remote:        Using activemodel 5.2.3
remote:        Using arel 9.0.0
remote:        Using activerecord 5.2.3
remote:        Using mimemagic 0.3.3
remote:        Using marcel 0.3.3
remote:        Using activestorage 5.2.3
remote:        Using execjs 2.7.0
remote:        Using autoprefixer-rails 9.7.1
remote:        Using bcrypt 3.1.13
remote:        Using msgpack 1.3.1
remote:        Using bootsnap 1.4.5
remote:        Using ffi 1.11.2
remote:        Using sassc 2.2.1
remote:        Using bootstrap-sass 3.4.1
remote:        Using will_paginate 3.2.1
remote:        Using bootstrap-will_paginate 1.0.0
remote:        Using bundler 2.0.2
remote:        Using coffee-script-source 1.12.2
remote:        Using coffee-script 2.4.1
remote:        Using method_source 0.9.2
remote:        Using thor 0.20.3
remote:        Using railties 5.2.3
remote:        Using coffee-rails 4.2.2
remote:        Using faker 2.2.0
remote:        Using gravtastic 3.2.6
remote:        Using jbuilder 2.9.1
remote:        Using jquery-rails 4.3.5
remote:        Using pg 0.20.0
remote:        Using puma 3.12.1
remote:        Using sprockets 3.7.2
remote:        Using sprockets-rails 3.2.1
remote:        Using rails 5.2.3
remote:        Using rb-fsevent 0.10.3
remote:        Using rb-inotify 0.10.0
remote:        Using sass-listen 4.0.0
remote:        Using sass 3.7.4
remote:        Using tilt 2.0.10
remote:        Using sass-rails 5.1.0
remote:        Using turbolinks-source 5.2.0
remote:        Using turbolinks 5.2.1
remote:        Using uglifier 4.2.0
remote:        Bundle complete! 31 Gemfile dependencies, 69 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Removing bundler (2.0.1)
remote:        Bundle completed (0.44s)
remote:        Cleaning up the bundler cache.
remote: -----> Installing node-v8.10.0-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NameError: undefined local variable or method `config_action_mailer' for #<SampleApp::Application:0x0000563ad4eeae70>
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/config/environments/production.rb:98:in `block in <top (required)>'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/railtie.rb:216:in `instance_eval'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/railtie.rb:216:in `configure'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/config/environments/production.rb:1:in `<top (required)>'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:602:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:601:in `each'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/engine.rb:601:in `block in <class:Engine>'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `each'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `tsort_each_child'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote:        /tmp/build_86c01264d697b18eed4ad26b2672a6eb/vendor/bundle/ruby/2.5.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to hidden-thicket-92473.
remote: 
To https://git.heroku.com/hidden-thicket-92473.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hidden-thicket-92473.git'

 

回答

以下の部分。

 

remote:        NameError: undefined local variable or method `config_action_mailer' for #<SampleApp::Application:0x0000563ad4eeae70>

 

「 config.action_mailer 」とすべきところを「config_action_mailer 」としてしまったことで「 undefined local variable or method 」が発生していました。

 

もうちょっと解説

当初以下の部分にエラー原因があると思い込み、ググって調べていました。

実際に様々な対処方法がヒットします。

 

当初エラー原因と思っていた箇所
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to hidden-thicket-92473.
remote: 
To https://git.heroku.com/hidden-thicket-92473.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/hidden-thicket-92473.git'

 

権限周りのエラーでこのようなエラーが出ることが多いらしいのですが、今回は違いました。

 

「 error 」「 rejected 」「 failed 」というキーワードが集中しているエラーログの最後の部分ばかり注目してしまったわけですが、思い込みは良くないですね。

 

教訓

エラー原因を調べる時はエラーログ全体を眺めるようにする。