tags:

views:

311

answers:

2

While trying to do:

perl -I'/v1/data/site_perl' -MCPAN -e 'install Log::Dispatch';

I continue to get "Can't locate Params/Validate.pm in @INC." When looking at the output, /v1/data/site_perl is NOT in the @INC displayed, even though I used -I.

I am not root so I have changed my CPAN config so that:

'makepl_arg' => q[LIB=/v1/data/site_perl INSTALLSITEMAN1DIR=/v1/data/site_perl/man/man1 INSTALLSITEMAN3DIR=/v1/data/site_perl/man/man3 INSTALLMAN1DIR=/v1/data/site_perl/man/man1 INSTALLMAN3DIR=/v1/data/site_perl/man/man3]

So even LIB is set.

In a basic script I have:

use lib '/v1/data/site_perl';
use Params::Validate;

With no problems.

How do I make the Log::Dispatch use lib /v1/data/site_perl without a force install? What am I missing?

+3  A: 

I believe CPAN.pm likes to call a lot of sub-processes for various tasks, and these end up starting new perls, which will not inherit your -I flag. Instead, try setting a PERL5LIB environment variable, e.g.

PERL5LIB='/v1/data/site_perl' perl -MCPAN -e 'install Log::Dispatch'

Another strategy to consider is to simply build a complete Perl installation in your local directory -- then use that perl's CPAN utilities. They will already have all your own paths built-in. This is the way I tend to do it.

friedo
Thank you for the quick and correct repsponse.
garrett
+2  A: 

You cannot install into a different CPAN directory using a simple -I flag. You can use the local::lib package to install a local set of libraries, or see this question and this question.

Ether
I used -I to add my non-root lib to @INC. Once the CPAN got to the primary module, it couldn't find the required recently installed modules because that instance of @INC didn't contain my directory. I didn't try setting PERL5LIB, which worked. local::lib is not installed on that machine, but soon will be! Thanks for the info.
garrett