ruby-on-railsactionviewruby-on-rails-6resolver

Rails 6, @unbound_templates is nil in actionview/lib/action_view/template/resolver.rb


Upgrading from Rails 5.2.3 to 6.0.0 or 6.0.1, with Ruby 2.6.3, after bundling succeeds, the rails app:update command has been carefully run, and webpacker updated, a request to any page that requires no authentication gives:

Puma caught this error: undefined method `clear' for nil:NilClass (NoMethodError)
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:181:in `clear_cache'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:16:in `each'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:16:in `each'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/lookup_context.rb:79:in `block in clear'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/lookup_context.rb:78:in `each'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/lookup_context.rb:78:in `clear'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/cache_expiry.rb:40:in `clear_cache'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/cache_expiry.rb:30:in `block (2 levels) in clear_cache_if_necessary'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/file_update_checker.rb:83:in `execute'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/cache_expiry.rb:32:in `block in clear_cache_if_necessary'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/cache_expiry.rb:23:in `synchronize'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/cache_expiry.rb:23:in `clear_cache_if_necessary'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/cache_expiry.rb:11:in `before'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `block in make_lambda'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:201:in `block (2 levels) in halting'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:607:in `block (2 levels) in default_terminator'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:606:in `catch'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:606:in `block in default_terminator'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:202:in `block in halting'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:514:in `block in invoke_before'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:514:in `each'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:514:in `invoke_before'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:111:in `run!'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:73:in `block in run!'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:70:in `tap'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/execution_wrapper.rb:70:in `run!'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/executor.rb:12:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/static.rb:126:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/webpacker-4.2.0/lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/engine.rb:526:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `public_send'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `method_missing'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/deflater.rb:34:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/configuration.rb:228:in `call'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/server.rb:667:in `handle_request'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/server.rb:470:in `process_client'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/server.rb:328:in `block in run'
/Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/thread_pool.rb:134:in `block in spawn_thread'

A second request to the same page gives:

Error during failsafe response: undefined method `compute_if_absent' for nil:NilClass
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:199:in `block in query'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:196:in `map'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:196:in `query'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:189:in `_find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:121:in `block in find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:156:in `block in cached'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:66:in `cache'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:155:in `cached'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/template/resolver.rb:120:in `find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:77:in `block (2 levels) in _find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:76:in `each'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:76:in `block in _find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:75:in `each'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:75:in `_find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:55:in `find_all'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/path_set.rb:48:in `find'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/lookup_context.rb:129:in `find'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/renderer/template_renderer.rb:47:in `determine_template'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/renderer/template_renderer.rb:9:in `render'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/renderer/renderer.rb:29:in `render_to_object'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/rendering.rb:118:in `block in _render_template'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/base.rb:304:in `in_rendering_context'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/rendering.rb:117:in `_render_template'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/streaming.rb:219:in `_render_template'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/rendering.rb:103:in `render_to_body'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/rendering.rb:52:in `render_to_body'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/renderers.rb:142:in `render_to_body'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/abstract_controller/rendering.rb:25:in `render'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/rendering.rb:36:in `render'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
  /Users/Emma/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/core_ext/benchmark.rb:14:in `ms'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/instrumentation.rb:85:in `cleanup_view_runtime'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.1/lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/instrumentation.rb:43:in `render'
  /Users/Emma/rails/consonance/app/controllers/exceptions_controller.rb:20:in `block (2 levels) in show'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/mime_responds.rb:214:in `respond_to'
  /Users/Emma/rails/consonance/app/controllers/exceptions_controller.rb:14:in `show'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/abstract_controller/base.rb:196:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/rendering.rb:30:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:135:in `run_callbacks'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/abstract_controller/callbacks.rb:41:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/rescue.rb:22:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/notifications.rb:180:in `block in instrument'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/notifications.rb:180:in `instrument'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activerecord-6.0.1/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/abstract_controller/base.rb:136:in `process'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionview-6.0.1/lib/action_view/rendering.rb:39:in `process'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal.rb:191:in `dispatch'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_controller/metal.rb:236:in `block in action'
  /Users/Emma/rails/consonance/config/application.rb:172:in `block in <class:Application>'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/show_exceptions.rb:51:in `render_exception'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/show_exceptions.rb:36:in `rescue in call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/rack/logger.rb:38:in `call_app'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/rack/logger.rb:26:in `block in call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/tagged_logging.rb:80:in `block in tagged'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/tagged_logging.rb:28:in `tagged'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/tagged_logging.rb:80:in `tagged'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/rack/logger.rb:26:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/request_store-1.4.1/lib/request_store/middleware.rb:19:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/request_id.rb:27:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/skylight-core-4.0.2/lib/skylight/core/probes/action_dispatch/request_id.rb:12:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/method_override.rb:22:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/runtime.rb:22:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/activesupport-6.0.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/executor.rb:14:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/static.rb:126:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/sendfile.rb:111:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/actionpack-6.0.1/lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/webpacker-4.2.0/lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/engine.rb:526:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `public_send'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/railties-6.0.1/lib/rails/railtie.rb:190:in `method_missing'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/rack-2.0.7/lib/rack/deflater.rb:34:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/configuration.rb:228:in `call'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/server.rb:667:in `handle_request'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/server.rb:470:in `process_client'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/server.rb:328:in `block in run'
  /Users/Emma/.rvm/gems/ruby-2.6.3/gems/puma-4.3.0/lib/puma/thread_pool.rb:134:in `block in spawn_thread'

This means that the @unbound_templates variable introduced here is nil. On a Rails console, Concurrent::Map.new works fine.

How can this instance variable, that gets set in the initializer, be nil?


Solution

  • I have the exact same error and I have had no progress debugging it thus far. My suspicion is that it is caused by a gem but I just don't know yet.

    @snowangel if you want to compare Gemfiles I've posted mine here: https://gist.github.com/biscuitvile/7bf0d4423ce0b2aa79e0ccc08bff4295