archive_me1Add my vote for this tag create new tag
, view all tags

Bug: Can't find libraries with mod_perl and 01Sep2004

When using 01Sep2004 with ModPerl, sometimes I get a Error 500 (Internal Server Error). I checked apache logs and saw that -- it's weird -- the @INC variable some times doesn't contain the /path/to/twiki/lib directory.

Should it be a mod_perl issue?

Test case

  • Install 01Sep2004 (can be from scratch)
  • Test it using regular CGI
  • Switch to mod_perl

I've made this script to test the contents of @INC, and, in fact, sometimes it lists the /path/to/twiki/lib, and sometimes it doesn't. frown


TWiki version: TWikiRelease01Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Debian testing, kernel 2.4.26
Web server: apache 1.3.31-5, mod_perl
Perl version: 5.8.4-2
Client OS: Debian
Web Browser: Mozilla 1.6 Mozilla/5.0 : (X11; U; Linux i686; pt-BR; rv:1.6) Gecko/20040413 Debian/1.6-5

-- AntonioTerceiro - 16 Sep 2004

Follow up

It's really weird. I've found some help in SettingLibPath. The setlib.cfg file is there (I've unpacked the distribution as it is), but sometimes the @INC simply doesn't contain the /path=to/twiki/lib.

It worked using

PerlSetEnv PERL5LIB /opt/twiki/lib

Well, it should not be necessary ...

-- AntonioTerceiro - 17 Sep 2004

This was one of the problems that drove me away from mod_perl and towards SpeedyCGI. I don't bother with mod_perl any more.

Just an idea, but could it be something to do with setlib.cfg use of relative paths? If the current directory changes in a mod_perl process, maybe the next time the process is used it starts up with the changed path. You could experiment with a

print STDERR "CWD IS ",`pwd`;
in setlib.cfg.

-- CrawfordCurrie - 18 Sep 2004

I found this in the #twiki irc logs:

Can't locate TWiki/UI/Edit.pm in @INC (@INC contains: . /usr/lib/perl5/5.8.3/i386-linux-thread-
multi /usr/lib/perl5/5.8.3 /usr/lib/perl5/site_perl/5.8.3/i386-linux-thread-multi 
/usr/lib/perl5/site_perl/5.8.2/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.1/i386-linux-thread-
multi /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.3 
/usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /u...

FiX: Make a small perl script with these two lines...

    #!/usr/bin/perl -wT
    unshift @INC, '/var/www/twiki/lib';

Load it with     PerlRequire /etc/httpd/conf.d/twiki_mod_perl_startup.pl  (example)

Works for me with mod_perl on Debian (testing) with Apache/1.3.31 Ben-SSL/1.55 (Debian GNU/Linux) PHP/4.3.8-12 mod_perl/1.29

-- MatthiasWientapper - 21 Sep 2004

If this works, can someone please document it (I guess in ModPerl?) and close this topic? Thanks.

-- CrawfordCurrie - 26 Sep 2004

Setting PerlSetEnv PERL5LIB [absolute path to twiki/lib] in httpd.conf also worked for me. As long as the problem itself is not fully understood I would not prefer to close this topic.

-- MatthiasWientapper - 02 Oct 2004

Neither solution worked for me (debian woody, apache 1.3.26)

A more radical (and efficient) solution is just to avoid re-reading a million times what is never changing anyways: just write directly the good value in the bin/ scripts, e.g:

for i in distro/bin/*;do 
  sed -e '/^ *# Set default current working directory/,/require .setlib[.]cfg.;/s/^/#/;s|BEGIN {.*|BEGIN { unshift @INC, "/var/www/twiki/lib";|' \ 
  <$i >installation/$i 

This comments out all the BEGIN block and replace it by: BEGIN { unshift @INC, "/var/www/twiki/lib"; }

A general solution would add also the $localPerlLibPath if needed.

-- ColasNahaboo - 14 Dec 2004

None of these suggested fixes will work properly if you are using mod_perl, you'll always get random 'module not found in @INC' messages in your server log. This is because the dorking around with @INC only lasts until the end of the first run of the script as the aforementioned dorking is in a BEGIN block. See http://perl.apache.org/docs/1.0/guide/porting.html#_INC_and_mod_perl:

"When running under mod_perl, once the server is up @INC is frozen and cannot be updated. The only opportunity to temporarily modify @INC is while the script or the module are loaded and compiled for the first time. After that its value is reset to the original one. The only way to change @INC permanently is to modify it at Apache startup."

See ModPerlUnix for a workaround.

-- AlanBurlison - 11 Mar 2006

Fix record

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatEXT testinc r1 manage 0.4 K 2004-09-16 - 23:15 AntonioTerceiro script for testing @INC and mod_perl
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2006-03-11 - AlanBurlison
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.