Project

General

Profile

Bug #18445

"Cannot define multiple 'included' blocks" for audit_extensions with eager_load enabled

Added by Dominic Cleal almost 2 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

When enabling eager_load within the development environment (not the default, edit config/environments/development.rb), Rails startup fails with the following error:

/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/concern.rb:126:in `included': Cannot define multiple 'included' blocks for a Concern (ActiveSupport::Concern::MultipleIncludedBlocks)
        from /home/dcleal/code/foreman/foreman/app/models/concerns/audit_extensions.rb:5:in `<module:AuditExtensions>'
        from /home/dcleal/code/foreman/foreman/app/models/concerns/audit_extensions.rb:2:in `<top (required)>'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:457:in `load'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:457:in `block in load_file'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:647:in `new_constants_in'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:456:in `load_file'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:354:in `require_or_load'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:317:in `depend_on'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:233:in `require_dependency'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/engine.rb:471:in `each'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/engine.rb:471:in `block in eager_load!'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/engine.rb:469:in `each'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/engine.rb:469:in `eager_load!'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/engine.rb:346:in `eager_load!'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/application/finisher.rb:56:in `each'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `run'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
        from /home/dcleal/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/application.rb:352:in `initialize!'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `public_send'
        from /home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/railties-4.2.7.1/lib/rails/railtie.rb:194:in `method_missing'
        from /home/dcleal/code/foreman/foreman/config/environment.rb:5:in `<top (required)>'

The same occurs if you call Rails.application.eager_load!.

Eager loading is enabled and works fine in production. The audit_extensions file gets loaded twice in the development environment, but in the production environment (where eager_load is true by default), it's only loaded once due to a different eager_load_paths configuration.

Moving the eager_load_paths configuration into the main application.rb, since it isn't environment-specific would be useful to allow eager loading to be enabled without errors in development, or for app.eager_load! to be called safely in development.


Related issues

Related to Foreman - Bug #19317: Plugin and dashboard widget registry auto-reloadedClosed2017-04-19
Related to Foreman - Bug #19318: Plugins infrastructure don't work reliably in developmentDuplicate2017-04-19

Associated revisions

Revision 7923c95d (diff)
Added by Dominic Cleal over 1 year ago

fixes #18445 - always define eager_load_paths, use require_dep

Allows `eager_load!` to be called or enabled in any environment without
loading files under lib/ twice. Switches many `require` calls to Rails'
`require_dependency` to always use its dependency loader, so when eager
loading it will track whether the file is loaded or not.

History

#1 Updated by The Foreman Bot almost 2 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4266 added

#2 Updated by Marek Hulán over 1 year ago

  • Legacy Backlogs Release (now unused) set to 240

#3 Updated by Dominic Cleal over 1 year ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Dominic Cleal over 1 year ago

  • Related to Bug #19317: Plugin and dashboard widget registry auto-reloaded added

#5 Updated by Ivan Necas over 1 year ago

  • Related to Bug #19318: Plugins infrastructure don't work reliably in development added

Also available in: Atom PDF