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

Enlightened monks,

I'm trying to check which modules are missing at the particular box which runs my script and install them if needed.

First part (check missing) is ok, but when I try to install module using
CPAN::Shell->install()
I get the followign error:
Can't locate package CPAN::Debug for @CPAN::Shell::ISA
despite of CPAN::Debug is present at PERL5LIB path

Any ideas what do I do wrong ?

P.S.: Debian Wheezy 3.2.0-4-amd64, perl 5.20.1
Sapienti sat.

Replies are listed 'Best First'.
Re: Problem installing missing modules with CPAN::Shell
by hotpelmen (Scribe) on Feb 10, 2015 at 17:32 UTC
    Unless you've done so I'd start with trivial checks:

    Verify CPAN::Debug is accessible when you do
    /path/to/perl -e 'use CPAN::Debug'
    If more than one version of Perl is installed, use full path for perl command to make sure you're installing the module for the correct version.
      I have only one perl version installed and when I do /usr/bin/perl -e "use CPAN::Debug" or /usr/bin/perl -MCPAN::Debug -e "print 1" everything is ok
      Sapienti sat.
      Well, I tried literally everything, including complete de- and re-installation of perl (and "rm -rf" of leftovers) but it did not help.

      Looks like a bug?

      Sapienti sat.

        Well, I tried literally everything, including complete de- and re-installation of perl (and "rm -rf" of leftovers) but it did not help.

        Looks like a bug?

        No. Looks like user error.

        Try this, get https://cpan.metacpan.org/authors/id/A/AN/ANDK/CPAN-2.05.tar.gz, untar it and install it

        Then try running ... and if it fails post the full error message including output of perl -V

Re: Problem installing missing modules with CPAN::Shell
by jmacloue (Beadle) on Feb 11, 2015 at 16:09 UTC

    Ahem, quite obvious suggestion but nevertheless - 99% of time if a module is found by  perl -MMod::Name but is not found by, for example, a CGI script that is because you have different environment in the console and in the script. Try checking $ENV{PERL5LIB} to see the difference, maybe you have some part of CPAN library installed locally for your user or something.

    As a side note - have you seen those Makefile.PL files in CPAN distributions? Maybe you are re-inventing the bike here, why not use a standard solution for the problem?