Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up separate Perl modules for non-login users?

Tags:

perl

cpan

Inspired of How can I use CPAN as a non-root user? i'd like to know, how to set up cpanm for non-login users (like www)? There is no login, so i don't know how to include some dir to @INC.

Edit: How i could set permanently enviroment var like PERL5LIB for non-login user? I can't set it from .bashrc (needs login) and not from /etc/environment (sets to everyone).

like image 252
w.k Avatar asked Oct 21 '22 00:10

w.k


1 Answers

Methods of changing @INC:

On a per-script basis:

  • use lib ...;
  • -Mlib=... on the shebang line.

On a per-process basis:

  • Set the PERL5LIB env var from the parent process.
    • sh: export PERL5LIB=... ; perl ...
    • sh: PERL5LIB=... perl ...
    • apache: SetEnv PERL5LIB ...

On a per-perl basis:

  • Specifying the directories for @INC when configuring perl when building it.
  • use lib ...; in a script named sitecustomize.pl in the directory returned by perl -V:sitelib.[1]

Of course, you could also install your own local Perl, perhaps using perlbrew.


Notes:

  1. Perl only looks for sitecustomize.pl if The perl has been configured to do with -Dusesitecustomize. Check with perl -V:usesitecustomize to see if it was.
like image 101
ikegami Avatar answered Oct 25 '22 18:10

ikegami