Dry-container error on rails (removed from the module tree but is still active!)

HI,

I’m using rails with dry-container and dry-auto-inject.

I get an error :

A copy of MyContainer has been removed from the module tree but is still active!

My container is load from an initializer (/config/initializers/load_container.rb) :

Import = Dry::AutoInject(MyContainer)

And my container look like :

class MyContainer
  extend Dry::Container::Mixin

  register("api.alias_insert") do
    Api::AliasInsert.new
  end

end

And I’m using like this in my controllers / classes :

class ConfirmationController < ApplicationController
include Import[alias_insert: “api.alias_insert”]

Any ideas ?

Pure guess but try this:

Rails.application.config.to_prepare do
  Import = Dry::AutoInject(MyContainer)
end

@xero88 did you try dry-system-rails? it handles code reloading.