Subject: | errors requiring modules |
When option require is set true, modules are required only from the
directories in @INC. This can result in errors when requiring modules
or surprising versions of modules being loaded when modules exist in
multiple locations.
Modules are required only from directories in @INC because
CORE::require is used to require them and CORE::require only searches
@INC - it ignores any directories specified in the search_dirs option.
Thus Module::Pluggable can find a plugin module in a directory
specified in the search_dirs option and then fail to load it.
Alternatively, if a module of the same name exists in one of the
directories in @INC then that module will be loaded rather than a
module of the same name that exists in one of the directories specified
in search_dirs. This might be surprising for users given the
documentation that says Module::Pluggable will look in the directories
in search_dirs before looking in those in @INC.
One option to fix this might be to localize @INC and prepend the
directories in search_dirs before calling require to require the module.