cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

yikes,

When I run perl -MCPAN -e'shell' to install a perl module, the lovely thingy decides to stick the modules in:

/usr/lib/perl5/site_perl
But @INC, in all its wisdom decides to only include look at directories under:
/usr/local/lib/perl5/site_perl

Yes, I know I can push @INC in my script, but what I want to know is:

"Is there any way to re-configure perl or the CPAN module so that modules added by CPAN can be found in @INC by default?

I heard that pushing into @INC effects taint mode, so would very much like to avoid this.

Any thoughts from the brothers and sisters?

cLive ;-)

Replies are listed 'Best First'.
Re: CPAN module and @INC
by andreychek (Parson) on Jul 01, 2001 at 10:15 UTC
    I unfortunatly do not know any methods to "permanently" change the @INC path, without recompiling Perl. Recompiling Perl always is an option though -- and if you are using some version of Linux, you could always use one of those prepackaged versions if you aren't in the mood to compile. If you choose to recompile, just check to make sure it's setting @INC paths properly at compile time (I believe it's a compile time option if I'm not mistaken).

    Since CPAN insists on putting things in /usr/lib/perl5 on your box, it sounds like your Perl install is confused. First off, are you certain that you don't have any rogue versions of Perl living in /usr/bin? If so, that could certainly cause the problem you're seeing now.

    However, assuming thats not the problem, and for some reason or another you don't really feel like recompiling everything, there are two fairly simple things you could do to remedy your problem:

  • The shell environment variable PERL5LIB acts just as @INC does.. or better said, it's like saying "use lib". Perl will search for modules in any directory listed in that variable, so you could set it for a particular user, or for the entire system in a login script.

  • Secondly, you could always symlink /usr/lib/perl5 to /usr/local/lib/perl5. In that case, anything CPAN installed would end up in your @INC every time. While it is a hack around another problem on your system, it would certaintly get you running quickly, and by all means there's nothing wrong with that.. it's just treating the symptom though, not the actual problem.
    -Eric
Re: CPAN module and @INC
by chipmunk (Parson) on Jul 01, 2001 at 19:59 UTC
    Are you sure that the perl you are using to run the CPAN shell is the same perl you are checking @INC with?

    I would expect the CPAN module to install modules based on the paths specified when perl was built, which suggests to me that you may have two separate builds of perl, one at /usr/bin/perl and another at /usr/local/bin/perl. I'm guessing that your @INC problems involve a script that starts with #!/usr/local/bin/perl.

    Use `which perl` to see what perl you're running from the command line, and compare the values for @INC from perl -V:

    /usr/bin/perl -V /usr/local/bin/perl -V
    If they show different paths, you'll probably want to pick one of the perl installions, replace the other binary with a link, and remove the set of libraries which is no longer needed. (To go along with the options in perl's Configure script, I'd suggest keeping /usr/local/bin/perl and making /usr/bin/perl a link.)
Re: CPAN module and @INC
by bikeNomad (Priest) on Jul 01, 2001 at 19:01 UTC
    Yes, you can re-compile Perl and change its INC path. If you go perl -V it will show you what the path is. You can also get the meaning of individual libraries from the %Config hash (use Config); see privlib, sitearch, sitelib, installarchlib, otherlibdirs, inc_version_list, incpath, and maybe others.

    To re-configure, use the Configure script in the root of the source directory and then re-compile.

Re: CPAN module and @INC
by cLive ;-) (Prior) on Jul 01, 2001 at 20:13 UTC
    In reply to some comments above:
    • chipmunk - nail head hit on you have - "whereis perl" pointed out the obvious
    • andreychek/BikeNomad - thank you - all valid and interesting points

    Funny how sometimes you can run around in circles looking for hard answers when you should be asking easy questions.

    Thanks all.

    cLive ;-)

    PS - Oh, FYI, it was a fresh Mandrake 8.0 install. This also has a screwy Apache httpd.conf editor GUI interface in it (puts directives in before associated modules are loaded) - but otherwise, lovely :)

Re: CPAN module and @INC
by cLive ;-) (Prior) on Jul 01, 2001 at 09:18 UTC
    s/effects/affects/s;

    oops