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

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

From: David Weintraub <qazwart_at_gmail.com>
Date: Thu, 4 Mar 2010 13:22:11 -0500

Did you log in as the user that runs the Subversion server (usually
the Apache user "apache" or "wwwrun" or some other user depending upon
the installation) and try your script? That way, you can verify that
this is not a permission issue.

I also wonder if you might be causing issues with putting the "use
lib" inside a BEGIN statement. This isn't necessary with "use lib" as
the manpage on the pragma states that these are ALMOST equivalent:

use lib /foo/bar;
BEGIN {unshift @INC, /foo/bar;}

The differences are subtle. The "use lib" won't execute if /foo/bar
doesn't exist. It'l also automatically include in the @INC array
before /foo/bar, the /foo/$archname/bar, /foo/$version/bar and
/foo/$archname/$version/bar directories (if they exist).

See <http://perldoc.perl.org/lib.html>.

On Thu, Mar 4, 2010 at 12:20 PM, Craig Thayer <CThayer_at_sensorlogic.com> wrote:
> David,
>
> Thank you for your reply.
>
> Yes, I have tested the script on the Subversion server and it runs just fine.  And I agree it is obvious that Perl is including the directories to my libraries (so the use lib statements are working as designed as you stated).  However, it is Perl that is complaining that it can't find my libraries even though they are clearly in the @INC path.  I have never run into this situation before and I believe it has to do with the fact that the Subversion hook is running with no environment defined, but why it makes Perl not able to find my libs ONLY when it runs as a Subversion hook I haven't a clue.
>
> I have temporarily resolved the problem by moving my libraries to the /usr/lib/perl5/site_perl path (which I didn't want to do) which is predefined by my Perl installation in @INC.  The script now runs via the Subversion hook and finds my libraries just fine.  I would, however, like to understand what causes Perl to not recognize my added paths to @INC when it runs as a Subversion hook.
>
> Craig
>
> -----Original Message-----
> From: David Weintraub [mailto:qazwart_at_gmail.com]
> Sent: Wednesday, March 03, 2010 9:57 PM
> To: Craig Thayer
> Cc: users_at_subversion.apache.org
> Subject: Re: Perl can't find my libraries when run via the subversion post-commit script
>
> On Wed, Mar 3, 2010 at 3:15 PM, Craig Thayer <CThayer_at_sensorlogic.com> wrote:
>> 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.
>
> Have you tried logging into the server as the user that runs
> Subversion and tried running the Perl script as that user (and not as
> part of the hook)? You might find the error when you try to execute as
> the user that is running the Subversion server.
>
> It is obvious that the Perl program is including the directories you
> want to include in the @INC array, so the problem is not in the use
> lib statements.
>
> I wonder if there is a permission issue going on -- especially since
> these are not standard Perl directories.
>
> --
> David Weintraub
> qazwart_at_gmail.com
>

-- 
David Weintraub
qazwart_at_gmail.com
Received on 2010-03-04 19:22:48 CET

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