Home > Software engineering >  cpan module install failed, no prereqs missing
cpan module install failed, no prereqs missing

Time:03-23

Just trying to install a CPAN module, don't seem to be missing any prereqs, and can't seem to find anything that points to what I need to do to fix this. Can someone make sense of what the issue might be? I'd rather not force install unless I'm absolutely sure its maybe just an issue with the tests. I've looked at previous questions and the issue is almost always a missing prereq module but doesn't seem to be the case here.

C:\Users\zacha>cpan XML::Liberal
CPAN: CPAN::SQLite loaded ok (v0.219)
Database was generated on Fri, 04 Mar 2022 11:36:42 GMT
Running install for module 'XML::Liberal'
CPAN: Digest::SHA loaded ok (v6.02)
CPAN: Compress::Zlib loaded ok (v2.1)
Checksum for C:\STRAWB~1\cpan\sources\authors\id\M\MI\MIYAGAWA\XML-Liberal-0.30.tar.gz ok
CPAN: Archive::Tar loaded ok (v2.38)
CPAN: YAML::XS loaded ok (v0.82)
CPAN: CPAN::Meta::Requirements loaded ok (v2.140)
CPAN: Parse::CPAN::Meta loaded ok (v2.150010)
CPAN: CPAN::Meta loaded ok (v2.150010)
CPAN: Module::CoreList loaded ok (v5.20210123)
Configuring M/MI/MIYAGAWA/XML-Liberal-0.30.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a gmake-style Makefile
Writing Makefile for XML::Liberal
Writing MYMETA.yml and MYMETA.json
  MIYAGAWA/XML-Liberal-0.30.tar.gz
  C:\Strawberry\perl\bin\perl.exe Makefile.PL -- OK
Running make for M/MI/MIYAGAWA/XML-Liberal-0.30.tar.gz
cp lib/XML/Liberal/Remedy/InvalidEncoding.pm blib\lib\XML\Liberal\Remedy\InvalidEncoding.pm
cp lib/XML/Liberal/Error.pm blib\lib\XML\Liberal\Error.pm
cp lib/XML/Liberal/LibXML.pm blib\lib\XML\Liberal\LibXML.pm
cp lib/XML/Liberal/Remedy/NestedCDATA.pm blib\lib\XML\Liberal\Remedy\NestedCDATA.pm
cp lib/XML/Liberal/Remedy/LowAsciiChars.pm blib\lib\XML\Liberal\Remedy\LowAsciiChars.pm
cp lib/XML/Liberal/Remedy/ControlCode.pm blib\lib\XML\Liberal\Remedy\ControlCode.pm
cp lib/XML/Liberal/Remedy/NotUTF8.pm blib\lib\XML\Liberal\Remedy\NotUTF8.pm
cp lib/XML/Liberal/Remedy/UnclosedHTML.pm blib\lib\XML\Liberal\Remedy\UnclosedHTML.pm
cp lib/XML/Liberal.pm blib\lib\XML\Liberal.pm
cp lib/XML/Liberal/Remedy/StandaloneAttribute.pm blib\lib\XML\Liberal\Remedy\StandaloneAttribute.pm
cp lib/XML/Liberal/Remedy/EntityRef.pm blib\lib\XML\Liberal\Remedy\EntityRef.pm
cp lib/XML/Liberal/Remedy/HTMLEntity.pm blib\lib\XML\Liberal\Remedy\HTMLEntity.pm
cp lib/XML/Liberal/Remedy/TrailingElements.pm blib\lib\XML\Liberal\Remedy\TrailingElements.pm
cp lib/XML/Liberal/Remedy/DeprecatedDTD.pm blib\lib\XML\Liberal\Remedy\DeprecatedDTD.pm
cp lib/XML/Liberal/Remedy/TrailingDoctype.pm blib\lib\XML\Liberal\Remedy\TrailingDoctype.pm
cp lib/XML/Liberal/Remedy/Declaration.pm blib\lib\XML\Liberal\Remedy\Declaration.pm
cp lib/XML/Liberal/Remedy/UndeclaredNS.pm blib\lib\XML\Liberal\Remedy\UndeclaredNS.pm
cp lib/XML/Liberal/Remedy/XHTMLEmptyTag.pm blib\lib\XML\Liberal\Remedy\XHTMLEmptyTag.pm
cp lib/XML/Liberal/Remedy/UnquotedAttribute.pm blib\lib\XML\Liberal\Remedy\UnquotedAttribute.pm
  MIYAGAWA/XML-Liberal-0.30.tar.gz
  C:\STRAWB~1\c\bin\gmake.exe -- OK
Running make test for MIYAGAWA/XML-Liberal-0.30.tar.gz
"C:\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'inc', 'blib\lib', 'blib\arch')" t/*.t
t/00_compile.t ......... Possible precedence issue with control flow operator at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Test/Builder.pm line 917.
t/00_compile.t ......... ok
t/01_bad.t ............. Possible precedence issue with control flow operator at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Test/Builder.pm line 917.
t/01_bad.t ............. 1/?
#   Failed test 'C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml'
#   at t/01_bad.t line 28.
#          got: 'parser error : Specification mandates value for attribute noshade at position 3:14 at t/01_bad.t line 27.
# '
#     expected: ''

#   Failed test 'created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isa XML::LibXML::Document'
#   at t/01_bad.t line 29.
#     created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isn't defined
Can't call method "toString" on an undefined value at t/01_bad.t line 33, <$fh> line 1.
# Looks like you failed 2 tests of 15.
# Looks like your test exited with 2 just after 15.
t/01_bad.t ............. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/15 subtests
t/02_global.t .......... Possible precedence issue with control flow operator at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Test/Builder.pm line 917.
t/02_global.t .......... 7/?
#   Failed test 'C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml'
#   at t/02_global.t line 19.
#          got: 'parser error : Specification mandates value for attribute noshade at position 3:14 at t/02_global.t line 18.
# '
#     expected: ''

#   Failed test 'created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isa XML::LibXML::Document'
#   at t/02_global.t line 20.
#     created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isn't defined

#   Failed test 'C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml'
#   at t/02_global.t line 25.
#          got: 'parser error : Specification mandates value for attribute noshade at position 3:14 at t/02_global.t line 24.
# '
#     expected: ''

#   Failed test 'created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isa XML::LibXML::Document'
#   at t/02_global.t line 26.
#     created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isn't defined

#   Failed test 'C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml'
#   at t/02_global.t line 30.
#          got: 'parser error : Specification mandates value for attribute noshade at position 3:14 at t/02_global.t line 29.
# '
#     expected: ''

#   Failed test 'created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isa XML::LibXML::Document'
#   at t/02_global.t line 31.
#     created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isn't defined
# Looks like you failed 6 tests of 144.
t/02_global.t .......... Dubious, test returned 6 (wstat 1536, 0x600)
Failed 6/144 subtests
t/03_global_destroy.t .. Possible precedence issue with control flow operator at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Test/Builder.pm line 917.
t/03_global_destroy.t .. 1/?
#   Failed test 'C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml'
#   at t/03_global_destroy.t line 24.
#          got: 'parser error : Specification mandates value for attribute noshade at position 3:14 at t/03_global_destroy.t line 23.
# '
#     expected: ''

#   Failed test 'created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isa XML::LibXML::Document'
#   at t/03_global_destroy.t line 25.
#     created DOM node with C:/STRAWB~1/cpan/build/XML-Liberal-0.30-3/t/bad/BAD-atttibute.xml isn't defined
t/03_global_destroy.t .. 55/? # Looks like you failed 2 tests of 71.
t/03_global_destroy.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/71 subtests
t/04_sanity.t .......... Possible precedence issue with control flow operator at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Test/Builder.pm line 917.
Redundant argument in sprintf at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Spiffy.pm line 232.
Redundant argument in sprintf at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Spiffy.pm line 232.
Redundant argument in sprintf at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Spiffy.pm line 232.
Redundant argument in sprintf at C:\STRAWB~1\cpan\build\XML-Liberal-0.30-3\inc/Spiffy.pm line 232.
t/04_sanity.t .......... 1/? parser error : Specification mandates value for attribute nofoo at position 2:12 at t/04_sanity.t line 6.
# Looks like your test exited with 2 just after 12.
t/04_sanity.t .......... Dubious, test returned 2 (wstat 512, 0x200)
All 12 subtests passed

Test Summary Report
-------------------
t/01_bad.t           (Wstat: 512 Tests: 15 Failed: 2)
  Failed tests:  14-15
  Non-zero exit status: 2
t/02_global.t        (Wstat: 1536 Tests: 144 Failed: 6)
  Failed tests:  19-24
  Non-zero exit status: 6
t/03_global_destroy.t (Wstat: 512 Tests: 71 Failed: 2)
  Failed tests:  10-11
  Non-zero exit status: 2
t/04_sanity.t        (Wstat: 512 Tests: 12 Failed: 0)
  Non-zero exit status: 2
Files=5, Tests=243,  2 wallclock secs ( 0.11 usr    0.06 sys =  0.17 CPU)
Result: FAIL
Failed 4/5 test programs. 10/243 subtests failed.
gmake: *** [Makefile:800: test_dynamic] Error 2
  MIYAGAWA/XML-Liberal-0.30.tar.gz
  C:\STRAWB~1\c\bin\gmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports MIYAGAWA/XML-Liberal-0.30.tar.gz
Stopping: 'install' failed for 'XML::Liberal'.

CodePudding user response:

There are two bugs in XML-Liberal-0.30.

Forcing the installation of the module is not recommended.

This will install the distribution:

wget https://cpan.metacpan.org/authors/id/M/MI/MIYAGAWA/XML-Liberal-0.30.tar.gz
tar xvzf XML-Liberal-0.30.tar.gz
cd XML-Liberal-0.30
perl -pe's/mandate/mandates?/' -i~ lib/XML/Liberal/Remedy/StandaloneAttribute.pm
perl -pe's/->extract_error\(\K\$\@/"\$\@"/' -i~ lib/XML/Liberal.pm
perl -I . Makefile.PL
make test
make install

The module's logic is basically the following:

  1. For up to 15 times by default:
    1. Try to parse the document using XML::LibXML while catching errors.
    2. If no errors occurred,
      1. Success (Return)
    3. For each error message,
      1. Apply a fix to the XML to attempt to resolve the error.
  2. Failure.

The issue at hand is that libxml2 has changed some of its error message. It used to emit

parser error : Specification mandate value for attribute ...

But the grammar mistake was fixed.

parser error : Specification mandates value for attribute ...

The fix is simple. In lib/XML/Liberal/Remedy/StandaloneAttribute.pm, replace

    my ($attr) = $error->message =~
        /^parser error : Specification mandate value for attribute (\w )/
            or return 0;

with

    my ($attr) = $error->message =~
        /^parser error : Specification mandates? value for attribute (\w )/
            or return 0;

(I'm assuming that some versions of libxml2 returned Specification mandate value. A web search seems to confirm this.)


The second issue is in how it parses error messages. I'm not exactly sure what the broken code is trying to do, but it can be worked around by replacing

my $error = $self->extract_error($@, \$xml);

with

my $error = $self->extract_error("$@", \$xml);

in XML/Liberal.pm.

  • Related