How do I install a CPAN module site-wide while local::lib is present?
Asked Answered
T

3

7

I've recently set up a new system and wanted to install Padre to check it out. The Padre install instructions specifically said to install local::lib, so I did so (although I've never had need of it before). I then went on my way installing several other modules, running CPAN from my normal user account with sudo to handle the root-required portions of the installation.

Then time came to test out one of the web apps these modules were needed to support and, lo and behold, apache couldn't find them. They loaded fine from the command line and a quick look in ~/perl5 confirmed my suspicion that local::lib had hijacked my CPAN sessions and installed these modules there instead of in a site-wide location, despite my CPAN config including

makepl_arg         [INSTALLDIRS=site]
mbuildpl_arg       [--installdirs site]

What do I need to do to my CPAN config so that modules will be installed site-wide even though local::lib is installed? Or will Padre work without it and I can just remove local::lib entirely?

(I do not want any modules installed under ~/perl5 unless Padre insists on them being there. My code under development has its own project-specific directory locations and everything else should be site-wide. I have no need for a private catch-all location.)

Tramel answered 22/10, 2010 at 14:54 Comment(2)
What does which perl show? If it is anything other than /usr/bin/perl, you might just want to invoke /usr/bin/perl -MCPAN -e shell.Musso
Good thought, but it does show /usr/bin/perl.Tramel
T
11

Got it. Per the instructions on local::lib's CPAN page, I had set export PERL_MM_OPT='INSTALL_BASE=~me/perl', which was overriding the setting in my CPAN config. A quick export PERL_MM_OPT= got me back to a proper install location.

On the one hand, that's what I get for following the instructions blindly. On the other, I would have expected o conf to show the actual config settings that are being used rather than those which are in the saved CPAN config (even if an environment variable is overriding them).

Tramel answered 22/10, 2010 at 17:14 Comment(2)
This is why I think local::lib, perlbrew, etc, although technically good, are socially bad. It's supposed to make things easier for people who understand the process already, not make it so you can ignore what it does for you.Bibliophage
long silence agreed, i ended up pulling my hair all out over a server problem with modules not upgrading properly for a user, found out it was because the account had local::lib and the modules were only being updated system wide. Now I am doomed to about 4 years (the length it took me to respond to this post) of putting my hairs back in their appropriate follicles.Lael
M
3

A quick export PERL_MM_OPT= got me back to a proper install location.

This didn't help me when I tried to install Starman globally. I had to edit /root/.bashrc to comment (or to delete) next lines:

  1. export PERL_LOCAL_LIB_ROOT="$PERL_LOCAL_LIB_ROOT:/root/perl5";
  2. export PERL_MB_OPT="--install_base /root/perl5";
  3. export PERL_MM_OPT="INSTALL_BASE=/root/perl5";
  4. export PERL5LIB="/root/perl5/lib/perl5:$PERL5LIB";
  5. export PATH="/root/perl5/bin:$PATH";
Masera answered 25/5, 2015 at 13:20 Comment(0)
P
1

Based on this comment, it seems that local::lib installs its own version of CPAN.pm. If this is the case, you may need to find the original CPAN.pm and make sure that that one is loaded when you run your CPAN shell. Something like:

perl -I /usr/lib/perl5 -MCPAN -e shell

might do it. You might also find perl -V useful to see what include path the Perl compiler is using for its modules.

Punchboard answered 22/10, 2010 at 15:8 Comment(7)
Nope, modules are still being installed under ~/perl5 even with -I /usr/lib/perl5 and all directories under ~/perl5 removed from @INC.Tramel
OK, this will tell you which CPAN.pm module is being loaded: perl -MCPAN -le 'print $INC{"CPAN.pm"}' What does it print?Punchboard
/usr/share/perl/5.10/CPAN.pmTramel
Looking into that file, it's $CPAN::VERSION = '1.9402';, so it appears to be a normal CPAN.pm.Tramel
OK, does FAQ number 5 from search.cpan.org/~andk/CPAN-1.9402/lib/CPAN.pm help?Punchboard
That came close, but not quite. It was PERL_MM_OPT causing the problem rather than any of those mentioned in that FAQ item. Thanks for helping to get me looking in the right direction!Tramel
Great. Glad you got there, anyway. :-)Punchboard

© 2022 - 2024 — McMap. All rights reserved.