3

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?

friedo
  • 65,762
  • 16
  • 114
  • 184
garrett
  • 207
  • 1
  • 5
  • 12
  • 1
    possible duplicate of http://stackoverflow.com/questions/102850/how-can-i-install-cpan-modules-locally-without-root-access-dynaloader-pm-line-22 and http://stackoverflow.com/questions/540640/how-can-i-install-a-cpan-module-into-a-local-directory – Ether Apr 12 '10 at 21:06

2 Answers2

3

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
  • 65,762
  • 16
  • 114
  • 184
2

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.

Community
  • 1
  • 1
Ether
  • 53,118
  • 13
  • 86
  • 159
  • 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 Apr 12 '10 at 21:55