4

I don't have root access to the system so I'm installing perl modules using local::lib which I installed using the bootstrapping method:

perl Makefile.PL --bootstrap=~/foo
make test && make install
echo '[ $SHLVL -eq 1 ] && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bash_profile

I then successfully installed cpanm and used cpanm to install the module FAST. However when I try use the fasgrep function I get the following error:

% fasgrep
Can't locate FAST.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /home/dpearton/perl5/bin/fasgrep line 5.

I've checked that FAST.pm is available in the local lib, it is but the system doesn't seem to be looking for it there.

according to the paths variables it should be looking in the right place:

$ echo PATH=$PATH ; env|sort|grep PERL
PERL5LIB=/home/dpearton/perl5/lib/perl5:/home/dpearton/perl5/lib/perl5
PERLBREW_BASHRC_VERSION=0.73
PERLBREW_HOME=/home/dpearton/.perlbrew
PERLBREW_ROOT=/home/dpearton/perl5/perlbrew
PERL_LOCAL_LIB_ROOT=/home/dpearton/perl5
PERL_MB_OPT=--install_base "/home/dpearton/perl5"
PERL_MM_OPT=INSTALL_BASE=/home/dpearton/perl5

I've even added export PER5LIB=$HOME/perl5/lib/perl5 to my .bash_profile and it still doesn't work.

I'm very new to using perl. Might the issue be that I've also got perlbrew installed? If so, how can I make a "clean" uninstall of prelbrew?

  • Run `which perl` to see if it is using your perlbrew Perl. – simbabque Sep 25 '15 at 13:48
  • Welcome to Stack Overflow! Regarding the question title: is it _consistently not findin_ (always), or is it _not consistently finding_ (sometimes it works) the module? Please [edit] the title if it's not what you meant, as it is confusing. – simbabque Sep 25 '15 at 13:49
  • It is sometimes finding the module. When I install using cpanm (which is not in the system perl) it works, but using scripts from the FAST package doesn't. – David Pearton Sep 25 '15 at 14:31
  • 1
    Did you restart `bash` after installing local::lib? – ikegami Sep 25 '15 at 14:32
  • @simbabque `which perl` shows that it is using the system perl - `/usr/bin/perl` – David Pearton Sep 25 '15 at 14:34
  • @ikegami Yes, I have restarted several times. – David Pearton Sep 25 '15 at 14:35
  • 3
    Note: You have at least two different builds of Perl on your machine, and you use the same PERL5LIB for both of them. That can cause problems. Specifically, it can result in errors trying to load modules. However, the particular error you asked about it not caused by this. – ikegami Sep 25 '15 at 15:06

1 Answers1

5

The shell in which you printed your environment shows PERL5LIB is set to add

/home/dpearton/perl5/lib/perl5

and

/home/dpearton/perl5/lib/perl5

to @INC, yet neither of those (identical) paths are found in @INC of the perl that tried to load FAST.pm.

Two possibilities:

  • That perl inherited a different environment than the one you dumped, or
  • That perl was started with -T (taint mode).

Check the shebang line of fasgrep to see if -T was used to rule out that possibility. I doubt that -T was used. It adds some safety checks to prevent user-input from ending up in executed commands. Removing -T would simply remove those checks. Since this script is neither externally accessible nor setuid, the benefits of -T are already quite minimal. If this is the issue, go ahead and remove it.

I suspect it's other possibility, especially since you showed fasgrep was started from a different prompt (%) than the one from which you ran set ($).

ikegami
  • 367,544
  • 15
  • 269
  • 518
  • Good thinking about taint mode! – simbabque Sep 25 '15 at 14:37
  • Checked the fasgrep script and it starts with `#!/usr/bin/perl -wT`. I do not know what the taint mode flag does, would removing it cause any other problems? It would be a pain to have manually edit all the scripts in the module! – David Pearton Sep 25 '15 at 14:48
  • 3
    It adds some safety checks to prevent user-input from ending up in executed commands. Removing `-T` would simply remove those checks. Since this script is neither externally accessible nor setuid, the benefits of `-T` are already quite minimal. Go ahead and remove it. – ikegami Sep 25 '15 at 15:00
  • @ikegami Thank you for the very clear and useful replies. I think the best idea going forwards would be to use the perlbrew build exclusively (set it up in the .bash_profile) with its library, because this is the one I can control, and remove the local lib. – David Pearton Sep 26 '15 at 13:16
  • Unless you plan on installing modules for your system Perl (`/usr/bin/perl` or whatever) without root priviledges, then I 100% agree; don't use local::lib. – ikegami Sep 26 '15 at 23:53