Project

General

Profile

Actions

Bug #18445

closed

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

Added by Dominic Cleal almost 8 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
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 2 (0 open2 closed)

Related to Foreman - Bug #19317: Plugin and dashboard widget registry auto-reloadedClosedDominic Cleal04/19/2017Actions
Related to Foreman - Bug #19318: Plugins infrastructure don't work reliably in developmentDuplicate04/19/2017Actions
Actions

Also available in: Atom PDF