tman77 has asked for the wisdom of the Perl Monks concerning the following question:

I've install several modules on a linux server using perl -MCPAN -e 'install Module::Name'

What I found out was that if I installed them under my username they install in /home/user/perl5/lib.

If I installed as sudo or root. its /root/perl5/lib/perl6/x86_64...

I'm used to the modules installing in /usr/local/lib64/perl5 or /usr/share/perl5/

So I have two questions.

First, how can I set CPAN so that if I install as root (so it has permissions to install correctly) it will place the perl modules on the system in the /usr/local/lib64/perl5 directory? I assume I need to configure CPAN via /root/.cpan/CPAN/MyConfig.pm? Or do I need to rerun a CPAN configuration command? I see the @INC has different files based on who I run perl -V as, root has /root and user has /home/user, in addition to the standard /usr/local/lib64/perl5, /usr/share/perl5/, etc

Second, can I just move or symlink the modules already installed under root to the /usr/local/lib64/perl5 directory?

Thanks in advance

Replies are listed 'Best First'.
Re: CPAN Module help
by choroba (Cardinal) on Jan 08, 2015 at 16:05 UTC
    Where cpan installs modules is decided based on various options, check
    o conf
    in the cpan shell. You can configure the options directly from the shell. In particular, mbuildpl_arg and  makepl_arg can contain prefix or install_base settings. Similarly, you can set the PERL_MB_OPT and PERL_MM_OPT environment variables, as local::lib does.

    I wouldn't recommend moving the modules. A path might be hardcoded somewhere which would break. Just configure cpan properly and reinstall.

    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      OK, do you mind being very specific. I ran perl -MCPAN -e shell.

      o conf shows me that mbuildpl_arg and makepl_arg are not set.
      They are set to [].

      The build dir is set to /root/.cpan/build.

      So can you give me an example of how I would set the correct config options so that CPAN will install the modules into the /usr/lib64/perl5/vendor_perl directory? Would I need to set more than the mbuild_install_arg?

        As a follow up, I tried setting the following via o conf and made sure I committed it

        makepl_arg [INSTALL_BASE=/usr/lib64/perl5/vendor_perl] mbuildpl_arg [--install_base=/usr/lib64/perl5/vendor_perl]

        And I then tried to install a module, and it still installed to /root/perl5/lib/perl5/x86_64-linux-thread-multi

        Do you have the mentioned variables set?
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ