On Fri, May 14, 2010 at 10:31 PM, Kartik Thakore via RT
<bug-par-pac...@rt.cpan.org> wrote:
>  Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=57494 >
> ...
> PAR::Packer can't seem to handle JSON::Any type packages.
>
> Here is a simple why to test this.
>
>  $ pp -B -M JSON::Any -M JSON::XS -M JSON -e 'use
> JSON::Any; my $j = JSON::Any->new'
>  $ ./json
> Couldn't find a JSON package. Need XS, JSON, or DWIW at
> script/ppXAgmN.pl line 1

(cc'ing to par mailing list)

Ouch! There are actually several problems here:

(1)  Simply

$ pp -o json -e 'use JSON::Any; 1;'

(when you have actually JSON::XS installed) should have worked -
at least it packed JSON/Any.pm and correctly inferred JSON/XS.pm
and packed it, too. But JSON::XS (as JSON::Any's first choice)
couldn't be loaded (see (2)), so JSON went on looking for JSON
which you had also explicitly packed. That couldn't be loaded either
(see (3)), so JSON::Any tried JSON::DWIW which wasn't packed.
So that's the error message you got. Note that JSON::Any suppresses
the actual errors from loading JSON::XS etc

(2) If you explicitly tried to pack JSON::XS, e.g.

$  pp -o jsonxs -e 'use JSON::XS; 1;'

you would have seen:

$ ./jsonxs
Can't locate attributes.pm in @INC (@INC contains: ...) at
/usr/lib/perl/5.12/DynaLoader.pm line 215.
BEGIN failed--compilation aborted.

But why is attributes.pm required (and hasn't been packed)? Turns out
the XS part of JSON::XS (i.e. JSON-XS-2.29/XS.xs) contains

SV *incr_text (JSON *self)
        ATTRS: lvalue
        CODE:
{
    ...

That's XS for Perl

sub incr_text : lvalue { ....

It's specifying an "lvalue" attribute on a subroutine. Either form causes the
Perl runtime to implicitly "require attributes". Of course, this
implicit requirement
can't be detected by Module::ScanDeps (which is used by PAR::Packer to find
recursively all modules used by your script ).

As an immediate band-aid for your problem, add "-M attributes"
to your pp command line and that should make at least JSON::XS
(and thus JSON::Any) work.

(3) As for JSON, if you tried

$  pp -o jasonpp -e 'use JSON; 1;'

you would have got

./jasonpp
Can't locate JSON/PP.pm in @INC (@INC contains: ...) at (eval 24) line 2.
 at script/pp7Jv9C.pl line 1
Compilation failed in require at script/pp7Jv9C.pl line 1.

So it's missing JSON/PP. But that in turn requires JSON/PP58 (or some
other JSON/PPnn depending on your actual version of perl).
This probably warrants a special rule in Module::ScanDeps.

Cheers, Roderich

Reply via email to