Darkwing has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
i tried to pack an older perl application having a lot of local modules using App::FatPacker::Simple. But when i tried to run the packed script, I got a "Can't locate Local/Foo/Bar.pm in @INC" error. By reducing the code step by step, I finally found out that the problem is caused by Exception::Class which is used for the exceptions. Small example:
File ./local/Local/Foo.pm
package Local::Foo; use strict; use warnings; sub foo_func { print("This is the Foo module\n"); } 1;
File ./local/Local/Exception.pm (note that the round parens and their content are commented out after Exception::Class.)
package Local::Exception; use strict; use warnings FATAL => 'all'; use Exporter 'import'; our @EXPORT = qw(throw_local); use Exception::Class #( # 'Local::Exception' => # { # description => 'My local exception', # alias => 'throw_local' # } #) ; 1;
File main.pl:
use strict; use warnings; use Local::Exception; BEGIN{ use Data::Dumper; print("\n>>>\n", Dumper(\@INC), "\n<<<\n"); } use Local::Foo; Local::Foo::foo_func();
The output (using Strawberry Perl 5.26) is as expected:
$VAR1 = [ bless( { 'Local/Exception.pm' => '#line 8 "main.fatpack.pl" package Local::Exception;use strict;use warnings FATAL=>\'all\';use Ex +porter \'import\';our@EXPORT=qw(throw_local);use Exception::Class ;1; ', 'Local/Foo.pm' => '#line 12 "main.fatpack.pl" package Local::Foo;use strict;use warnings;sub foo_func {print("This i +s the Foo module\\n")}1; ' }, 'FatPacked::41105272' ), '.\\local', 'C:/Strawberry-perl-5.26.3.1-64bit/perl/site/lib', 'C:/Strawberry-perl-5.26.3.1-64bit/perl/vendor/lib', 'C:/Strawberry-perl-5.26.3.1-64bit/perl/lib' ]; <<< This is the Foo module
It is also correct for Strawberry Perl 5.14, 5.38 and Perl 5.34 on Ubuntu. But if i remove the comment chars changing Local::Exception to:
package Local::Exception; use strict; use warnings FATAL => 'all'; use Exporter 'import'; our @EXPORT = qw(throw_local); use Exception::Class ( 'Local::Exception' => { description => 'My local exception', alias => 'throw_local' } ) ; 1;
Then i get:
>>> $VAR1 = [ 'C:/Strawberry-perl-5.26.3.1-64bit/perl/vendor/lib/Exception +/Class.pm', '.\\local', 'C:/Strawberry-perl-5.26.3.1-64bit/perl/site/lib', 'C:/Strawberry-perl-5.26.3.1-64bit/perl/vendor/lib', 'C:/Strawberry-perl-5.26.3.1-64bit/perl/lib' ]; <<< Can't locate Local/Foo.pm in @INC (you may need to install the Local:: +Foo module) (@INC contains: C:/Strawberry-perl-5.26.3.1-64bit/perl/ve +ndor/lib/Exception/Class.pm .\local C:/Strawberry-perl-5.26.3.1-64bit +/perl/site/lib C:/Strawberry-perl-5.26.3.1-64bit/perl/vendor/lib C:/S +trawberry-perl-5.26.3.1-64bit/perl/lib) at main.fatpack.pl line 59. BEGIN failed--compilation aborted at main.fatpack.pl line 59.
The structure that fatpacker adds to @INC is gone causing the error. Basically the same error i get for 5.14 and 5.34. It only works for Strawberry Perl 5.38. Seems that something has been fixed in Perl between 5.34 and 5.38.
Is this a known problem? Is there a workaround for older Perl versions? It would be best if it worked for 5.14, but I could live with 5.34 as well.
|
---|