4

recently I was installing some perl modules on my RHEL 5 with perl version 5.8.8 and all instalations went fine. I can see that the modules exist in the @INC but my TWiki site claims that it can't find them returning an error: Can't locate Net/LDAP.pm in @INC (a lot of paths which contain the modules) at TWiki.pm line xx. When I do perl -e 'use Net::LDAP'; it doesn't return anything which means perl can find that module. Also TWiki was configured corectly and works fine except the plugins that use specific modules I had to install, I've even added the paths to setLib.cfg just in case.

Edit:

which perl returns /usr/bin/perl

the shebang line of twiki/cgi-bin/view is #!/usr/bin/perl -wT

perl -MNet::LDAP -e 'print $INC{"Net/LDAP.pm"}, "\n";' returns:

/usr/lib/perl5/site_perl/5.8.8/Net/LDAP.pm

apache error logs show: [Tue Nov 16 10:53:47 2010] [error] [client 10.76.14.170] [Tue Nov 16 10:53:47 2010] view: INC /usr/lib/perl5/site_perl/5.8.8 at /usr/local/apache2/htdocs/twiki5_pdc/bin/view line 44. So it use's the correct path.

Miky
  • 942
  • 2
  • 14
  • 29

5 Answers5

4

@INC is possibly different from your command line - either because you're using a different Perl interpreter binary, or other factors affecting @INC.

Check command line's @INC: perl -e 'print join(",", sort @INC);' - and compare to @INC printed in your Wiki's error that you mentioned.

You might have to add directories to your web server's Perl's @INC which are present in command line's ("how" depends on whether you're running under mod_perl or not).

Community
  • 1
  • 1
DVK
  • 126,886
  • 32
  • 213
  • 327
  • I am not using mod_perl and the "Software error: " (the one on the browser which I assume is the @INC of the web server?) contain the same paths as the command line @INC (the one i checked with the command you gave me). Also how can I view the @INC of the web server, I don't remember configuring any perl paths in my apache configuration. – Miky Nov 10 '10 at 16:22
3

What Apache thinks your INC path is and what your command-line Perl thinks your INC path are usually two completely different things. You may have to set the environment variable PERL5LIB in your Apache configuration.

I'm a big fan of TWiki/FOSwiki and have encountered this issue several times in the past.

PP.
  • 10,764
  • 7
  • 45
  • 59
2
  1. Do this (it works in a good number of cases):

    perldoc -l Net::LDAP
    

    If there is POD in the file, it will point you to the .pm. Even so, if it points you to a .pod file, the .pm is usually in the same directory.

  2. Then check that list after the @INC( and see if the path is in there. You will probably need to modify the environment that Apache runs in, because it probably will not be in there.


Since, that didn't work for you, this should:

perl -MNet::LDAP -e 'print $INC{"Net/LDAP.pm"}, "\n";'

If perl is actually loading it, that will tell you where it's loading it from.

Axeman
  • 29,660
  • 2
  • 47
  • 102
  • No documentation found for "Net::LDAP". Although I did that command in the "/" directory , before when I've done it in some other directory it worked, I think I was in the directory used to build the Net/LDAP module , it returned a file LDAP.POD and it had a symlink but I guess that wasn't the one that was installed in the system, just the leftovers of the isntalaltion. – Miky Nov 10 '10 at 16:24
  • @user452730: try the new suggestion. – Axeman Nov 10 '10 at 16:33
  • Hmmm now I get the same error I get in the browser: [michal@bumas_tst ~]$ perl -MNet::LDAP -e 'use 5.010; say $INC{"Net/LDAP.pm"};' Can't locate Net/LDAP.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .). BEGIN failed--compilation aborted. – Miky Nov 10 '10 at 16:44
  • Oh wait, on a 2nd try with the last command you suggested to use I am getting a path which describes the location of Net:LDAP. So perl does load it. "/usr/lib/perl5/site_perl/5.8.8/Net/LDAP.pm" – Miky Nov 16 '10 at 09:17
1

Horses: Have you reviewed the installation guide to make sure that everything's configured correctly?

Zebras: edit bin/twiki_cgi and add right before $TWiki::engine->run():

warn "ENV $_ => $ENV{$_}" for sort keys %ENV;
warn "INC $_" for @INC;

grep your apache error log for the rows with ENV and INC. Look for ENV rows with PERL5LIB or PERLLIB. Check INC rows to make sure the directories containing your CPAN libraries are listed.

converter42
  • 7,400
  • 2
  • 29
  • 24
  • Nice this was useful and I have some questions: Is that dot in the 2nd view correct, whats the meaning of it? And are some lines with double slashes also correct? (like i.e. /usr/local/apache2/htdocs/twiki5_pdc/lib/CPAN/lib//5.8.8/x86_64-linux-thread-multi). view: INC /usr/local/apache2/htdocs/twiki5_pdc/lib at /usr/local/apache2/htdocs/twiki5_pdc/bin/view line 44. view: INC . at /usr/local/apache2/htdocs/twiki5_pdc/bin/view line 44. – Miky Nov 16 '10 at 09:57
  • The dot in @INC tells perl to search the current working directory for libraries. On a unixish platform multiple, contiguous path delimiters are treated as a single delimiter (// and ///// are the same as /). – converter42 Nov 16 '10 at 22:49
1

Ok the reason was most probably that I was installing the perl modules as root and they were not set executable for others so apache couldn't execute/use them.

Miky
  • 942
  • 2
  • 14
  • 29