Skip Menu |

This queue is for tickets about the MooseX-Object-Pluggable CPAN distribution.

Report information
The Basics
Id: 88562
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: MooseX-Object-Pluggable

People
Owner: Nobody in particular
Requestors: ether [...] cpan.org
Cc: gortan [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: load_plugin does not die, nor even return false, if loading plugin did not work
If loading a plugin fails (e.g. the underlying module is missing some prereqs), load_plugin should return false, so the caller can bail out or take other action. As an example of how things can go wrong: t/load_plugins.t in the Devel-REPL repository attempts to load all plugins, skipping the test if 'use $class' failed. Devel::REPL::Plugin::CompletionDriver::Globals builds on top of Devel::REPL::Plugin::Completion, which in turn depends on optional prereqs. When ::Globals calls load_plugin('Completion'), we need to find out at compile time that this failed, so we can also die (at compile time), rather than waiting until the test calls load_plugin('CompletionDriver::Globals') (which causes a failing test). This is easy to reproduce by running t/load_plugins from the 1.003021 release, without installing any of the optional features.
On Mon Sep 09 19:54:51 2013, ETHER wrote: Show quoted text
> If loading a plugin fails (e.g. the underlying module is missing some > prereqs), load_plugin should return false, so the caller can bail out > or take other action.
This pull requests tries to improve load_plugin(s) to handle plugin load errors more graceful, while giving the caller control over whether he wants to die or continue: https://github.com/moose/MooseX-Object-Pluggable/pull/2
On 2014-01-06 08:29:51, GORTAN wrote: Show quoted text
> On Mon Sep 09 19:54:51 2013, ETHER wrote:
> > If loading a plugin fails (e.g. the underlying module is missing some > > prereqs), load_plugin should return false, so the caller can bail out > > or take other action.
> > This pull requests tries to improve load_plugin(s) to handle plugin > load errors more graceful, while giving the caller control over > whether he wants to die or continue: > https://github.com/moose/MooseX-Object-Pluggable/pull/2
The diagnosis of this ticket is incorrect, and the wrong solution was selected. What was happening in Devel::REPL is that the same plugin (role) was attempted to be loaded more than once in the same runtime. Because of the heuristics used in Class::Load::load_class to determine if a module has already been loaded, subsequent load_class($plugin) attempts were not dying, allowing for a much later death in the application when it tried to use that plugin. That problem is outlined in more detail in https://rt.cpan.org/Ticket/Display.html?id=63013. At any rate, I don't think it's safe to change the API so strongly as to soften a die into a warning. However, your test cases did provide a good foundation for diagnosing the root problem, and your code changes to load each plugin individually and update internal state variables incrementally is correct. We just want to continue to die on failure! All these fixes will be released shortly. Thanks again!