It appears that, after beating my head slightly, simply changing my environment variable from PERLLIB to PERL5LIB fixes an odd problem.

Quick background: local install to ~/perl. In order for cpan to properly detect pre-reqs that it just installed, you need to set the environment to include all the proper locations. So I just put this in a file, I called it 'sp' (short for "set perl environment" - if I'm going to make a short cut, I emphasise short), and just run ". ~/sp":

export PERLLIB=`find $HOME/perl -name 5.8.8 -o -name aix* -o -name sit +e* | \ xargs perl -e 'print join ":",@ARGV'`
(I'm sure I could do that with just perl, no find, but, hey, the point is lazy, not perl purity.) As long as I'm being lazy, I omit the '5' in 'PERL5LIB' because, well, perlrun says that when PERL5LIB isn't set, it falls back to PERLLIB. That turns out to be true for perl. But not for everything else. Specifically, if you're installing something that requires another module that is also not core (and thus in your local module directory), and, I think, the current module also uses MM instead of Module::Build (though maybe I just didn't hit it with MB), I think the PERL5LIB gets set, basically ignoring your PERLLIB, and suddenly things can't be found, and tests fail. Miserably.

Adding in the 5 again, and suddenly "cpan -i Perl::Critic" works just fine. Ugh. Shortcuts that aren't. Don't use PERLLIB. Use PERL5LIB. Because that seems to be what some others are doing, and you'll get bit otherwise. Woops.

Replies are listed 'Best First'.
Re: PERLLIB vs PERL5LIB: not quite the same
by JavaFan (Canon) on Jan 08, 2010 at 10:41 UTC
    IIRC, PERL5LIB was introduced around the time perl5 say the light (hence the name), and it allowed people to have both a perl4 and a perl5 installation, using PERLLIB for perl4, and PERL5LIB for perl5.

    So, I guess your complaint is "CPAN doesn't work with perl4" ;-)

      I think it's for that reason (i.e. being a Perl 4 thingy) that PERLLIB is tagged as obsolete in many people's heads (including mine) — for example see Motivation behind PERL5LIB and PERLLIB?.

      I'm wondering, however, has it ever been officially deprecated for Perl 5? And if so, shouldn't there be a recommendation in perlrun etc. to use PERL5LIB by default these days?

Re: PERLLIB vs PERL5LIB: not quite the same
by Anonymous Monk on Jan 08, 2010 at 07:51 UTC
    If I understand you correctly, cpan is setting the PERL5LIB variable and thus overriding your pre-existing PERLLIB? A bug report sound better than avoiding PERLLIB because of badly behaving programs :)