Bug #22080
closeduninitialized constant ActionView::Template::Handlers::Rabl
Description
After the commit for #3763 went in, my production build DEB instance shows:
uninitialized constant ActionView::Template::Handlers::Rabl (NameError) /usr/share/foreman/config/initializers/rabl_init.rb:73:in `<top (required)>' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:655:in `block in load_config_initializer' /usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-5.1.4/lib/active_support/notifications.rb:168:in `instrument' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:654:in `load_config_initializer' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:611:in `each' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers' /usr/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each' /usr/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' /usr/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from' /usr/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from' /usr/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `each' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:48:in `tsort_each_child' /usr/lib/ruby/2.3.0/tsort.rb:415:in `call' /usr/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from' /usr/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component' /usr/lib/ruby/2.3.0/tsort.rb:347:in `each' /usr/lib/ruby/2.3.0/tsort.rb:347:in `call' /usr/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component' /usr/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each' /usr/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in `public_send' /usr/share/foreman/vendor/ruby/2.3.0/gems/railties-5.1.4/lib/rails/railtie.rb:185:in `method_missing' /usr/share/foreman/config/environment.rb:5:in `<top (required)>' config.ru:3:in `require' config.ru:3:in `block in <main>' /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval' /usr/share/foreman/vendor/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize' config.ru:1:in `new' config.ru:1:in `<main>' /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval' /usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app' /usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>' /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>' /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
Reverting d73b91986d7c fixes it.
Files
Updated by Anonymous about 7 years ago
- Related to Feature #3763: Ability for engine/plugin to extend RABL responses added
Updated by Timo Goebel about 7 years ago
I am unable to reproduce this on one of my RHEL production host. I might need some help with this. Maybe this only happens on Debian?
Anyway, this constant is defined here:
https://github.com/nesquena/rabl/blob/11c51e36987bdb7fc63cccbc499312ff8564a02a/lib/rabl/template.rb#L43-L63
It should be loaded as soon as we require 'rabl' in the initializer:
https://github.com/nesquena/rabl/blob/11c51e36987bdb7fc63cccbc499312ff8564a02a/lib/rabl.rb#L86-L88
Updated by Shimon Shtein about 7 years ago
After a short investigation, I have found the reason for this bug.
TL;DR: ActionView::Base should be loaded before Rabl handler is monkey patched (https://github.com/theforeman/foreman/blob/536799c3400c56f2fe38772bf64fd6be8c0810f8/config/initializers/rabl_init.rb#L73).
In the current code we use font-awesome-sass which is loaded before rabl_init.rb that does for us.
Here is the stack snip for proper initialization (that is missing in the provided gemfile.lock):
foreman/gems/font-awesome-sass-4.6.2/lib/font_awesome/sass/rails/railtie.rb @ line 8 foreman/gems/actionview-5.1.4/lib/action_view/base.rb @ line 139 foreman/gems/actionview-5.1.4/lib/action_view/base.rb @ line 215 foreman/gems/rabl-0.13.1/lib/rabl/railtie.rb @ line 5
Updated by The Foreman Bot about 7 years ago
- Status changed from New to Ready For Testing
- Assignee set to Timo Goebel
- Pull request https://github.com/theforeman/foreman/pull/5143 added
Updated by Timo Goebel about 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset 299a8f8d4c51fa2404e9caefc5158190303d8de3.