[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Perl can't find my libraries when run via the subversion post-commit script

From: Craig Thayer <CThayer_at_sensorlogic.com>
Date: Wed, 3 Mar 2010 14:15:37 -0600

I am at a loss as to why my perl script cannot find my libraries when invoked by the subversion post-commit script. My script runs just fine when invoked manually in a terminal window. I'm aware that the subversion post-commit script runs with no environment defined, but the error I'm getting (below) makes no sense since the module perl claims it can't find (Log.pm) is, in fact, in the '/root/perl5/lib' directory which is clearly listed in the @INC array.

The problem is most likely a perl issue, but since the problem only occurs when my script is run via the subversion post-commit operation I'm hoping that someone else has run into this issue with subversion hooks executing a perl script and can enlighten me as to what I'm missing here. It acts like perl is compiling the 'use' statements BEFORE it compiles the BEGIN section-which comes first.

Here is the error reported by the commit operation when it runs the post-commit script (which calls my svn-post-commit.pl script):
'post-commit' hook failed with error output:
Can't locate Log.pm in @INC (@INC contains: lib ../lib /root/perl5/lib /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 .) at /var/svn/repos/cirrus/hooks/svn-post-commit.pl line 96.
BEGIN failed--compilation aborted at /var/svn/repos/cirrus/hooks/svn-post-commit.pl line 96.

My script adds the path '/root/perl5/lib' to the @INC array in the BEGIN section and my 'use Log' statement is in the main body after the BEGIN section. I've tried several different methods for trying to get perl to find my libraries to no avail (including exporting the PERL5LIB EV in the post-commit script before calling my script and using the 'require' function-but this creates a whole new set of problems with libraries included by the libraries and I don't want to have to hard code paths to libraries in all my modules). And I don't want to place our libraries in one of the perl library paths-which perl seems to have no trouble finding libraries installed with it package (e.g., File::Basename, Net::SMTP, etc.).

post-commit script called by subversion commit:
/var/svn/repos/cirrus/hooks/svn-post-commit.pl "$REPOS" "$REV"

Snippet of my svn-post-commit.pl perl script called via the post-commit script:
use strict;
use warnings;
use File::Basename;
use Getopt::Long;
use Net::SMTP;
               use lib "/root/perl5/lib";
               use lib "../lib";
               use lib "lib";

use Log;
use Singleton;
use Timestamp;

System information:
Server info:
CentOS 2.6.18-164.6.1.el5 x86_64 x86_64 x86_64 GNU/Linux
Subversion v1.4.2
Perl v5.8.8

Client Info:
Subversion Client: TortoiseSVN 1.6.7, Build 18415 - 64 Bit , 2010/01/22 17:55:06
Commit operation was performed from my Windows 7 machine, but the subversion repository and hook scripts are on a Linux server.

Any help would be greatly appreciated!
Received on 2010-03-04 00:43:15 CET

This is an archived mail posted to the Subversion Users mailing list.