On Rails::Initializer, configuration.load_once_paths is frozen but config.load_paths is not.
We need to freeze them so future modifications will fail rather than do nothing mysteriously. For example, I was changing the variable on my environment/development.rb and the path I was setting was never loaded.
To fix, just add the line:
configuration.load_paths.freeze
To railties/lib/initializer.rb, method set_autoload_paths, around line 214.
So we will have:
def set_autoload_paths Dependencies.load_paths = configuration.load_paths.uniq Dependencies.load_once_paths = configuration.load_once_paths.uniq
extra = Dependencies.load_once_paths - Dependencies.load_paths unless extra.empty? abort <<-end_error load_once_paths must be a subset of the load_paths. Extra items in load_once_paths: #{extra * ','} end_error end
# Freeze the arrays so future modifications will fail rather than do nothing mysteriously configuration.load_paths.freeze configuration.load_once_paths.freeze end