Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Why is cpanm installing Perl5 modules in the wrong spot?

by Arunbear (Prior)
on Feb 07, 2021 at 16:43 UTC ( #11128020=note: print w/replies, xml ) Need Help??


in reply to Why is cpanm installing Perl5 modules in the wrong spot?

cpanm plays it safe by default to avoid interfering with the system Perl, but it does give hints of how to circumvent this e.g.
+% cpanm -n Attempt ! ! Can't write to /usr/local/share/perl5 and /usr/local/bin: Installing + modules to /home/arun/perl5 ! To turn off this warning, you have to do one of the following: ! - run me as a root or with --sudo option (to install to /usr/local +/share/perl5 and /usr/local/bin) | - run me with --local-lib option e.g. cpanm --local-lib=~/perl5 ! - Set PERL_CPANM_OPT="--local-lib=~/perl5" environment variable (i +n your shell rc file) ! - Configure local::lib in your shell to set PERL_MM_OPT etc. ! --> Working on Attempt Fetching http://search.cpan.org/CPAN/authors/id/M/MA/MARKF/Attempt-1.0 +1.tar.gz ... OK Configuring Attempt-1.01 ... OK Building Attempt-1.01 ... OK Successfully installed Attempt-1.01 1 distribution installed
i.e. run it as a root or with the --sudo option, but really this is the less safe option.

Also you can avoid adding a 'use lib ...' by setting the PERL5LIB env variable (which looks already set going by what you've shown above).

Replies are listed 'Best First'.
Re^2: Why is cpanm installing Perl5 modules in the wrong spot?
by hippo (Bishop) on Feb 07, 2021 at 17:17 UTC
    run it as a root or with the --sudo option

    FWIW, I would always use --sudo instead of running cpanm with elevated privs so that the build and test phases are run as the unprivileged user. It is only the installation into the protected directories which requires root access and that's what --sudo does. You are still trusting the module author for that final installation phase, of course.


    🦛

      I suspect the "less safe option" comment wasn't meant to say that running as root is better than using sudo, but rather was an attempt to scare the user away from wanting to do a system-wide install at all. (i.e., "running as root or using sudo is less safe than a local-lib install") Because the current fad is to treat the system perl as if it's made of plutonium and should never be approached or touched in any way at all.
Re^2: Why is cpanm installing Perl5 modules in the wrong spot?
by cormanaz (Deacon) on Feb 08, 2021 at 15:19 UTC
    What made me post this to begin with is that my Komodo IDE/debugger was saying a module I hasd installed with cpanm couldn't be found. But after reading your comment that the ENV variable should take care of this, I created a little test script to run from the command line, and Perl found one of the cpanm modules just fine. So the issue seems to be that that debugger is not reading the ENV variable somehow.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128020]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2021-10-15 20:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (68 votes). Check out past polls.

    Notices?