thomas11 has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I'm trying to package up a Perl script --- Module::ScanDeps' own scandeps.pl --- along with its dependencies, so I can easily run it on another machine that lacks these dependencies.

Using PAR, there are two options: create a Perl script, or create a stand-alone executable.

Trying to create a Perl script with
pp -P -B -o scandeps.par.pl `which scandeps.pl`
I get
$ perl ~/scandeps.par.pl 7tmr_stats_updater.pl 
No such file or directory at /work/software/perlbrew/perls/current/bin/par.pl line 855.
I had expected a standalone script to not depend on par.pl, but maybe I misunderstood. Trying to create a stand-alone executable with
pp -o scandeps `which scandeps.pl`
fails because the target machine's glibc is older than the one on the build machine, so the perl that pp embeds cannot run.

Is there a way I can package scandeps.pl with all its (Perl) dependencies, and run the resulting bundle with the target machine's perl?

Replies are listed 'Best First'.
Re: PAR packaging woes
by Anonymous Monk on Nov 02, 2010 at 18:04 UTC
    No such file or directory at /work/software/perlbrew/perls/current/bin +/par.pl line 855.
    I had expected a standalone script to not depend on par.pl
    I don't think that error message is telling you that par.pl itself is missing, but rather that something which par.pl is trying to do in line 855 is causing a "no such file or directory" error.

    Perhaps taking a look at that line will give you a clue what's going wrong?

      Thanks! Gotta learn to actually read the error messages... The failing line is an "eval { require Carp::Heavy }". This goes away when not including the core with -B.

      Unfortunately, now I get "Can't locate PAR/Heavy.pm". Even explicitly including the module using -M, as in

      pp -P -M PAR::Heavy -o scandeps.par.pl `which scandeps.pl`
      doesn't work, still the same error. I verified that the module gets included, but it isn't found at runtime.

Re: PAR packaging woes
by Anonymous Monk on Nov 02, 2010 at 19:33 UTC
    Is there a way I can package scandeps.pl with all its (Perl) dependencies, and run the resulting bundle with the target machine's perl?

    Yeah, don't pack the core for starters

Re: PAR packaging woes
by lamprecht (Friar) on Nov 03, 2010 at 17:11 UTC
    Hi,

    I doubt, that your approach will give you the desired results: Even if you are successful packaging scandeps.pl using pp, it will pull in a lot more modules than actually needed. The packed modules will mask the ones actually present on the system you try to examine, therefore you can't rely on version numbers and dependencies of these modules.
    Module::ScanDeps has only core dependencies from perl 5.10 on and only few if you need to run it on 5.8.
    see http://deps.cpantesters.org/?module=Module%3A%3AScanDeps&perl=5.12.1&os=any+OS