Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

shared perlbrew running as root

by rootcho (Pilgrim)
on Feb 01, 2013 at 18:39 UTC ( #1016598=perlquestion: print w/replies, xml ) Need Help??
rootcho has asked for the wisdom of the Perl Monks concerning the following question:

I have perlbrew installed in one of my user accounts and what to be able to use it from root.
I configured root ./.bashrc to have :
export PERLBREW_ROOT=/home/userx/perl5/perlbrew
source $PERLBREW_ROOT/etc/bashrc
also :
root# perlbrew list
* perl-5.17.8
So far so good I can run perl scripts from bash-console as root
The problem is if I try to run perl script inside a bash script, I get complains about modules not found :
Can't locate Time/ in @INC (@INC contains: /home/userx/perl5/perlbrew/perls/perl-5.17.8/bin/../lib /usr/local/lib64/perl5 ...
And yes if I try to do :
root# perldoc Time::HiRes
Can't find any loadable formatter class in Pod::Perldoc::Toman Pod::Perldoc::Toman ...
But if I check in my userx account I can see the package here :
And of course doing perldoc Time::HiRes from usex account works.
userx$ cpanm Time::HiRes
Time::HiRes is up to date. (1.9725)
What could be the problem... it seems like PERLLIB problem ? and how to solve it..

PS> And of course I have this in the bash script :
export PERLBREW_ROOT=/home/userx/perl5/perlbrew
export PERLBREW_HOME=~/.perlbrew
source ${PERLBREW_ROOT}/etc/bashrc

Replies are listed 'Best First'.
Re: shared perlbrew running as root
by chexmix (Hermit) on Feb 01, 2013 at 21:23 UTC
    Try running

    env | grep PERL5LIB

    both as userx and as root. I admit up front I don't know anything about perlbrew, but I agree it does sound like a library issue. If you get a certain value for PERL5LIB as userx and nothing as root, I'd try setting PERL5LIB for root to whatever it is you got as userx.

    Or alternately, use a 'use lib' statement in scripts owned by root.


      In both cases there is no PERL5LIB
Re: shared perlbrew running as root (perlbrew switch)
by Anonymous Monk on Feb 01, 2013 at 23:05 UTC
    What does perlbrew switch say?
      # perlbrew switch
      Currently switched to perl-5.17.8