Subject: | Fails to handle required *and* optional dependency |
Some modules have recently started recommended a specific version of a hard dependency that has no required version. Class::Load, for example, has ‘requires: Data::OptList: '0'’ and ‘recommends: Data::OptList: '0,110'’.
CPAN.pm does not handle this very well. The sequence that it goes through is set out at <https://rt.cpan.org/Ticket/Display.html?id=123447>.
I see a similar problem with Module::Pluggable. The META.yml contains this:
optional_features:
module_runtime:
description: 'Optionally use Module::Runtime for requiring plugins rather than homegrown system'
requires:
Module::Runtime: '0.012'
recommends:
Module::Runtime: '0.012'
I must admit I’ve never heard of optional_features. But in any case, the CPAN shell really gets muddled up:
Show quoted text
nolock_cpan> test IO::Async::SSL
... processes a bunch of dependencies, eventually getting to Module::Pluggable ...
Configuring S/SI/SIMONW/Module-Pluggable-5.2.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Module::Pluggable
Writing MYMETA.yml and MYMETA.json
SIMONW/Module-Pluggable-5.2.tar.gz
/usr/local/bin/perl5.26.0 Makefile.PL -- OK
Running make for S/SI/SIMONW/Module-Pluggable-5.2.tar.gz
Show quoted text---- Unsatisfied dependencies detected during ----
---- SIMONW/Module-Pluggable-5.2.tar.gz ----
Module::Runtime [requires,optional]
See the ‘requires,optional’ thing, which I also observe with Class::Load. It builds and tests:
cp lib/Devel/InnerPackage.pm blib/lib/Devel/InnerPackage.pm
cp lib/Module/Pluggable.pm blib/lib/Module/Pluggable.pm
cp lib/Module/Pluggable/Object.pm blib/lib/Module/Pluggable/Object.pm
Manifying 3 pod documents
SIMONW/Module-Pluggable-5.2.tar.gz
/usr/bin/make -- OK
Running make test
... etc etc etc ...
All tests successful.
Files=43, Tests=180, 5 wallclock secs ( 0.17 usr 0.09 sys + 3.55 cusr 0.87 csys = 4.68 CPU)
Result: PASS
SIMONW/Module-Pluggable-5.2.tar.gz
Tests succeeded but one dependency not OK (Module::Runtime)
Then it goes ahead and tests Module::Runtime, but still remembers that Module::Pluggable is ‘not ok’, so it is not included in PERL5LIB for subsequent tests, and so everything else fails in the end.
Regardless of how this is handled, it should not be saying ‘but one dependency not OK’ before even trying to test that dependency!