Consider removing custom `eager_load_paths` from configuration
Description
We should consider removing custom entries from eager_load_paths
.
config.eager_load_paths.push(*%W(#{config.root}/lib
#{config.root}/app/models/ci
#{config.root}/app/models/hooks
#{config.root}/app/models/members
#{config.root}/app/models/project_services
#{config.root}/app/workers/concerns
#{config.root}/app/services/concerns))
Adding directories that are already in autoload_paths
to eager_load_paths
might cause difficult to debug problems.
As en example, we have a Ci::Pipeline
class located in app/models/ci
:
eager_load_paths
With [1] pry(main)> 'Pipeline'.safe_constantize
LoadError: Unable to autoload constant Pipeline, expected /home/grzesiek/gdk/gitlab/app/models/ci/pipeline.rb to define it
from /home/grzesiek/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:495:in `load_missing_constant'
[2] pry(main)>
This behavior causes problems with ETags
middleware. We had to add wrap_parameters Ci::Pipeline
to controller using ETags to workaround it.
eager_load_paths
Without [1] pry(main)> 'Pipeline'.safe_constantize
=> nil
[2] pry(main)>
Proposal
-
Check if this is safe in production environment. -
Consider removing custom eager_load_paths
.