Defect #36801
openRails Autoload Paths contain plugin libs twice
0%
Description
Due to the way plugins are loaded by Redmine the variable
ActiveSupport::Dependencies.autoload_paths
contains the path to the 'lib' directory of each plugin twice, which should not happen.
When Redmine loads the plugins from config/initializers/30-redmine.rb
it calls
Redmine::Plugin.load
Redmine::Plugin.load
(defined in lib/redmine/plugin.rb
) adds the 'lib' directory of each plugin to
ActiveSupport::Dependencies.autoload_paths
and to
$LOAD_PATH #alias $:
When each plugin calls
Redmine::Plugin.register
from init.rb (which they ought to do), then in Redmine::Plugin.register
all Rails paths in the plugin directory are created by calling
engine_cfg.paths
implicitly by calling
engine_cfg.paths.add 'lib', eager_load: true
Then in Redmine::Plugin.register
the following call causes the second addition of the autoload_paths
ActiveSupport::Dependencies.autoload_paths +=
engine_cfg.eager_load_paths + engine_cfg.autoload_once_paths + engine_cfg.autoload_paths
In some environments this may cause trouble.
Updated by Stephan Wenzel over 2 years ago
A fix could be adding
ActiveSupport::Dependencies.autoload_paths.uniq
as the last line in @Redmine::Plugin.load
Updated by Marius BÄ‚LTEANU over 2 years ago
Can you test on current trunk where we switched the autoloading from classic to zeitwerk (#29914)?