Skip Menu |

This queue is for tickets about the App-FatPacker CPAN distribution.

Report information
The Basics
Id: 122337
Status: open
Priority: 0/
Queue: App-FatPacker

People
Owner: Nobody in particular
Requestors: ivan.malich [...] isper.sk
Cc:
AdminCc:

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



Subject: 2 bugs in App::FatPack (./fatlib/ empty, Quote::Sub not included in output)
Date: Mon, 3 Jul 2017 14:14:23 +0200
To: bug-App-FatPacker [...] rt.cpan.org
From: Ivan Malich <ivan.malich [...] isper.sk>
Hello, I found 2 bugs in App::FatPack when I tried to pack some Moo modules. The description and possible fix/workaround bellow. ico bug description ^^^^^^^^^^^^^^^ - test program: small script with Moo'ed module, all non-core modules installed via cpanm - fatpack is unable to create working scripts, doesn't include needed libraries (Moo in this case). The directory ./fatlib/ is empty. - this error is possible to fix by using absolute $pack_base path - when using also some "has y => (...);" properties in module, Quote::Sub isn't included in resulting packed script - this error goes away when "use Quote::Sub;" is in script installing ^^^^^^^^^^ $ uname -a Linux puding 4.9.27 #2 SMP Tue May 9 15:04:33 CDT 2017 x86_64 Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz GenuineIntel GNU/Linux $ perl -v This is perl 5, version 22, subversion 2 (v5.22.2) built for x86_64-linux-thread-multi... $ mkdir fatpack $ cd fatpack $ wget https://raw.githubusercontent.com/miyagawa/cpanminus/master/cpanm $ chmod 755 cpanm $ ./cpanm -l perl5lib Moo App::FatPacker ...... installed some modules... Successfully installed Moo-2.003002 Successfully installed App-FatPacker-0.010007 trying to pack... and failing ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ $ cat > fp.pl << END #!/usr/bin/env perl package X; use Moo; has y => (qw< is ro required 1 >); 1; my \$x = X->new(y => 1); print "OK\n" if \$x; END # this of course doesn't work: $ ./fp.pl Can't locate Moo.pm in @INC (you may need to install the Moo module) (@INC contains: /usr/ BEGIN failed--compilation aborted at ./fp.pl line 6. # but this works $ PERL5LIB=perl5lib/lib/perl5 ./fp.pl OK # packing doesn't work (./fatlib/ is empty): $ PERL5LIB=perl5lib/lib/perl5 ./perl5lib/bin/fatpack pack fp.pl > fp.pl.packed fp.pl syntax OK $ chmod 577 fp.pl.packed $ ./fp.pl.packed Can't locate Moo.pm in @INC (you may need to install the Moo module) (@INC contains: FatPa BEGIN failed--compilation aborted at ./fp.pl.packed line 48. fixing ./fatlib/ ^^^^^^^^^^^^^^^^ # apply this patch: $ cat > empty_fatlib.patch << END --- perl5lib/lib/perl5/App/FatPacker.pm.orig 2017-07-03 13:25:06.488256878 +0200 +++ perl5lib/lib/perl5/App/FatPacker.pm 2017-07-03 13:27:30.997272198 +0200 @@ -4,7 +4,7 @@ use warnings FATAL => 'all'; use 5.008001; use Getopt::Long; -use Cwd qw(cwd); +use Cwd qw(cwd abs_path); use File::Find qw(find); use File::Spec::Functions qw( catdir splitpath splitdir catpath rel2abs abs2rel @@ -187,7 +187,7 @@ # if the last bit is a number it's $Config{archname}/$version/auto # so use $p-3 in that case my $version_lib = 0+!!($dir_parts[$p-1] =~ /^[0-9.]+$/); - $pack_base = catpath $vol, catdir @dir_parts[0..$p-(2+$version_lib)]; + $pack_base = abs_path(catpath $vol, catdir @dir_parts[0..$p-(2+$version_lib)]); last PART; } } END $ patch -Np0 < empty_fatlib.patch patching file perl5lib/lib/perl5/App/FatPacker.pm # try it ... and get different error $ PERL5LIB=perl5lib/lib/perl5 ./perl5lib/bin/fatpack pack fp.pl > fp.pl.packed fp.pl syntax OK $ ./fp.pl.packed Can't locate Sub/Quote.pm in @INC (you may need to install the Sub::Quote module) (@INC co BEGIN failed--compilation aborted at ./fp.pl.packed line 862. Compilation failed in require at ./fp.pl.packed line 1860. fixing also Sub::Quote (ehm... workarounding it) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ $ cat > fp.pl << END #!/usr/bin/env perl package X; use Sub::Quote; # just to make fatpack work use Moo; has y => (qw< is ro required 1 >); 1; my \$x = X->new(y => 1); print "OK\n" if \$x; END # fatpack it $ PERL5LIB=perl5lib/lib/perl5 ./perl5lib/bin/fatpack pack fp.pl > fp.pl.packed fp.pl syntax OK # and it works! $ ./fp.pl.packed OK
From: Ryan Erwin
As of December 9th 2017, I'm getting the exact same behavior on multiple systems. I've tried running this under CentOS 7.4 (perl 5.16.3) and under Ubuntu 16.04 (perl 5.22.1) and I'm getting the exact same behavior in both of them. Would be great if this patch could be added into FatPack, otherwise I suspect it will hit all new users. Note that RT's line wrapping breaks the patch... Anyone who applies this will need to manually unwrap the "pack_base" line in the patch... Show quoted text
> -use Cwd qw(cwd); > +use Cwd qw(cwd abs_path);
Show quoted text
> -$pack_base = catpath $vol, catdir @dir_parts[0..$p-(2+$version_lib)]; > +$pack_base = abs_path(catpath $vol, catdir > @dir_parts[0..$p-(2+$version_lib)]);
Of course still having to "use Sub::Quote" needs a different fix, but I can confirm that's what will get your packed module to function.