...making Linux just a little more fun!

Problem with installing a local module

Ben Okopnik [ben at okopnik.com]

Mon, 14 Feb 2011 20:30:43 -0500

Hi, Rui -

I assume that you wanted to send this question to The Answer Gang rather than asking me for a private consult (those tend to be expensive :), so I've forwarded it there. Please direct any further emails about it there (tag@lists.linuxgazette.net), and I'll try to answer your questions.

On Tue, Feb 08, 2011 at 11:33:53AM +0000, Rui Fernandes wrote:

> Dear Ben Okopnik,
> I've read your article "Installing Perl Modules as a Non-Root User", and
> regarding including the "myperl" in @INC" it worked. But now I have a problem,
> that maybe you can help.
> I▓m trying to install a local module in a webserver that isn▓t mine. I get no
> error with the following Makefile.PL

Do you mean when you run 'make', 'make test', 'make install', or all of them?

>  #!/usr/local/bin/perl
> use 5.008007;
> use ExtUtils::MakeMaker;
> # See lib/ExtUtils/MakeMaker.pm for details of how to influence
> # the contents of the Makefile that is written.
> WriteMakefile(
>     NAME              => 'Kepler',
>     VERSION_FROM      => 'lib/Kepler.pm', # finds $VERSION
>     PREREQ_PM         => {}, # e.g., Module::Name => 1.1
>     ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
>       (ABSTRACT_FROM  => 'lib/Kepler.pm', # retrieve abstract from module
>        AUTHOR         => 'Rui Fernandes <rui.kepler@gmail.com>') : ()),
>     LIBS              => ['-L/home/username/usr/local/lib -lswe'], # e.g.,
> '-lm'
> #    LIBS              => ['-lswe'], # e.g., '-lm'
>     DEFINE            => '', # e.g., '-DHAVE_SOMETHING'
>     INC               => '-I/home/username/usr/local/include', # e.g., '-I. -I/
> usr/include/other'
>     INSTALL_BASE      => '/home/username/myperl',
> #    DISTVNAME         => 'perl_kepler', #
>  # Un-comment this if you add C files to link with later:
>     # OBJECT            => '$(O_FILES)', # link all the C files too
> );
> But when I run the test script, the module isn't found, not even in the "myperl
> /lib" directory.

I'm having trouble parsing that last sentence. Do you mean the module is actually not in myperl/lib, or does your test script not find it?

I suspect that it's the latter. If that's the case, then what's happening is that your web server isn't seeing the correct path. This often happens because the actual path to your home directory is not necessarily the same thing as you see when you log in via, say, SSH. For example, in one of my former webservers, the path reported by 'pwd' when I was in my home directory was '/home/ben' - but the real path was something like '/homepages/41/d322536930/'. As a result, using '/home/ben/myperl' as part of my 'use lib' statement was worthless: the web server didn't know anything about a path like that.

Perhaps the easiest way to find out what the server is seeing as your real path is to look at the server environment. Here's an easy way to do that with Perl:

#!/usr/bin/env perl
# Created by Ben Okopnik on Fri Sep 27 09:50:30 PDT 2002
use warnings;
use CGI qw/:standard/;
print header, start_html("CGI environment"), p("CGI environment"), hr,
    pre(map({sprintf("%-25s=>\t%s\n", $_, $ENV{$_})} sort keys %ENV)),
    hr, end_html;

Drop this script (I call it 'info.cgi') into your CGI directory and pull it up in your browser. This will report your CGI environment - including what the web server sees as the actual path to the script. You should be able to figure out your 'use lib' directory argument from there.


                       OKOPNIK CONSULTING
        Custom Computing Solutions For Your Business
Expert-led Training | Dynamic, vital websites | Custom programming
  443-250-7895   http://okopnik.com   http://twitter.com/okopnik

Top    Back