Fix Sidekiq loading problem: Cannot define multiple included blocks for a Concern

1 minute read

Out Of Date Warning

This article was published on 02/11/2015, this means the content may be out of date or no longer relevant.
You should verify that the technical information in this article is still up to date before relying upon it for your own purposes.

Starting Sidekiq in development/test, we got this problem:

Cannot define multiple 'included' blocks for a Concern
/home/user/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.4/lib/active_support/concern.rb:126:in `included'
/home/user/.rvm/gems/ruby-2.1.2/bundler/gems/our-gem-3f4ecd7d8fb2/app/models/somemodel/model:9:in `'

Turns out, our file which uses the included do...end feature was loaded twice and that is not supported by a ActiveSupport::Concern.


  1. Replace all occurrences of require 'file_with_concern' with require_dependency 'file_with_concern'.
  2. - OR - switch to eager_loading for Sidekiq:
# config/environments/development.rb
MyApp::Application.configure do

  config.cache_classes = !!Sidekiq.server?
  config.eager_load = !!Sidekiq.server?

See mperham/sidekiq#1791 and mperham/sidekiq#447.

If you are unsure, who calls that file, you can modify the file with an editor and add some statements to the top of the file:

puts "FILE #{__FILE__} LOADED BY:"
puts caller.to_a.reject{|l| l['gems/ruby-2.1.2/gems/']}.join("\n")

# rest of the file

When running the Sidekiq process, you will see the output with the call stack for that file.