Wednesday, August 12, 2009

PAR and Module::Scandeps vs autobox

PAR is a handy tool for dealing with your Perl application's many dependencies.
You can quickly bundle up the app + all requirements, and then run it on other machines. It's great when you don't feel like building half of CPAN just to run a temporary utility somewhere.

It generally works fairly well, but it relies upon Module::ScanDeps to report what those dependencies are.

And unfortunately I've been totally stumped by it when the autobox module is involved.. but only on the Debian Etch (4.0 and 4.5) platform; it works fine on Ubuntu 8.10 and 9.04.

To demonstrate, take the following mini script:

#!/usr/bin/perl
use strict;
use warnings;
use autobox;

print "Hello world!"->length;

sub SCALAR::length {
return length(shift);
}


Now run this to build a .par file from it:
pp -p -o test.par test.pl

Now we know that the test script used autobox.. So this test.par should contain autobox.pm and autobox.so, right?

$ unzip -l test.par|grep autobox
$

Wrong. Where did it go?
Attempting to run the resulting par on another etch system does, predictably, fail due to a missing autobox module.

Running the same commands on Ubuntu 9.04 work just fine. Both systems are running the latest version of PAR, PAR::Packer, and Module::ScanDeps.

6 comments:

  1. Is autobox install on machine where it fails to add it to par archive?

    ReplyDelete
  2. Module::ScanDeps requires that the modules it detects as potential dependencies are available from the system it's running on. That is, if you're scanning a script in an environment where it wouldn't run in the first place, the dependencies will be wrong.

    ReplyDelete
  3. autobox is installed on the machine I am building the PAR upon.

    The script runs fine on that system.

    However if I build a par and then try the par on another machine, it does not run because autobox is missing.

    ReplyDelete
  4. Well, if it's not in the .par, of course it doesn't run.

    To eliminate part of the problem, try running the "scandeps.pl" program on the script instead of using pp to package it. The output on a computer without autobox available (also check "perl -Mautobox -e1") is:

    'threads' => '1.71',
    'AutoLoader' => '5.68',
    'Cwd' => '3.2701',
    'File::Spec' => '3.2701',
    'File::Spec::Unix' => '3.2701',
    'List::Util::PP' => '1.21',
    'List::Util' => '1.21',
    'Scalar::Util::PP' => '1.21',
    'Scalar::Util' => '1.21',

    Whereas after installing autobox on the same machine, I get:
    'threads' => '1.71',
    'Cwd' => '3.2701',
    'File::Spec' => '3.2701',
    'File::Spec::Unix' => '3.2701',
    'List::Util::PP' => '1.21',
    'List::Util' => '1.21',
    'Scalar::Util::PP' => '1.21',
    'AutoLoader' => '5.68',
    'Scope::Guard' => '0.03',
    'autobox::universal' => 'undef',
    'Scalar::Util' => '1.21',
    'autobox' => '2.55',

    If this is the output you get, packaging will work just fine:
    pp -o t.par -p t.pl
    unzip t.par | grep autobox
    extracting: lib/auto/autobox/autobox.bs
    inflating: lib/auto/autobox/autobox.so
    inflating: lib/autobox.pm
    inflating: lib/autobox/universal.pm

    Also make sure you have recent versions of PAR, PAR::Packer, and Module::ScanDeps if this still fails.

    ReplyDelete
  5. As per my original post, all machines are already running the latest versions of PAR, PAR-Packer, and Module-ScanDeps.

    The machines which are *building* the PAR files *do* have autobox installed, and the scripts run fine there.

    The problem does indeed seem to be that Module-ScanDeps doesn't *see* autobox as a requirement, even though it is one.. but only on the Debian Etch and Win32 machines.

    The question is -- why?

    ReplyDelete
  6. Quite likely a Module::ScanDeps bug. It's by far the most fragile part of the whole PAR toolchain. Further debugging should probably go in the direction of checking why M::SD doesn't find the autobox files on your system. Maybe play with manually adding a few directories to PERL5LIB (or within scandeps.pl to @INC)? Since I can't reproduce the issue, I can't really help you much with the debugging.

    I suppose bringing this up on the par@perl.org mailing list may turn up more or better ideas. I only found your blog post by chance (and the ironman aggregator).

    Cheers,
    Steffen

    ReplyDelete