[sf-perl] /usr/local/foo/ for cpan and locally grown modules

David Alban extasia at extasia.org
Sat Feb 17 14:02:47 PST 2007


FYI, this didn't work:

  perl Makefile.PL PREFIX=/usr/local/FOO

That is, using PREFIX=/usr/local/FOO didn't cause a cpan module to be
installed in the /usr/local/FOO tree such that I could include it
with:

    use lib "/usr/local/FOO/lib/perl";
    use Some::Module;

But this does work (/usr/local/FOO/lib/perl is a symlink to perl5):

  perl Makefile.PL LIB=/usr/local/FOO/perl5

It caused, for example, Crypt::PasswdMD5 to be installed as:

  /usr/local/FOO/lib/perl5/Crypt/PasswdMD5.pm

Which is the same location I'm putting home grown modules.

So now I have a single:

  use lib "/usr/local/FOO/lib/perl";

statement that works both for home grown and installed-from-cpan modules.

Yay!

On 1/29/07, David Alban <extasia at extasia.org> wrote:
> (Assume I'm not allowed to update the "live" perl installation, so I'm
> installing modules in the /usr/local/FOO tree.)  I have:
>
> $ find /usr/local/FOO/lib/perl5 -type f
> /usr/local/FOO/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/Crypt/PasswdMD5/.packlist
> /usr/local/FOO/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/perllocal.pod
> /usr/local/FOO/lib/perl5/site_perl/5.8.0/Crypt/PasswdMD5.pm
> /usr/local/FOO/lib/perl5/Log/Transcript.pm
>
> Crypt::PasswdMD5 is from CPAN.  I took Garth's suggestion and did:
>
>   $ perl Makefile.PL PREFIX=/usr/local/FOO
>
> and the files were installed as shown above.  Log::Transcript is the
> module I wrote.
>
> Ideally, I'd like to have users be able to include a single "use ..."
> statement in the code.[1]  I'd like it to be:
>
>   use lib "/usr/local/FOO/lib/perl5";
>         # or /usr/local/FOO/lib/perl if I make the latter a symlink to
> the former
>
> Not two:
>
>   use lib "/usr/local/FOO/lib/perl5";
>   use lib "/usr/local/FOO/lib/perl5/site_perl";
>
> Based on Quinn's suggestion, I thought the former might allow a
> program to pick up both Log::Transcript (or, home-grown modules) and
> Crypt::PasswdMD5 (or, cpan installed modules).  But it doesn't pick up
> the site_perl tree:
>
> $ unset PERL5LIB; perl -I/usr/local/FOO/lib/perl5 -MCrypt::PasswdMD5 -e 1
> Can't locate Crypt/PasswdMD5.pm in @INC (@INC contains:
> /usr/local/FOO/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/local/FOO/lib/perl5/5.8.0 /usr/local/FOO/lib/perl5
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .).
> BEGIN failed--compilation aborted.
>
> It's a little clearer here:
>
> $ unset PERL5LIB; perl -I/usr/local/FOO/lib/perl5 -e 'print join "\n", @INC'
> /usr/local/FOO/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/local/FOO/lib/perl5/5.8.0
> /usr/local/FOO/lib/perl5
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0
> /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0
> /usr/lib/perl5/vendor_perl
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/5.8.0
>
> Am I missing something that I can use to get a single:
>
>   use lib "/usr/local/FOO/lib/perl5";
>
> statement to work (i.e., to include the site_perl tree, too)?
>
> Thanks,
> David
>
> [1] There's no hope of getting them to set PERL5LIB in their environment
>
> On 1/25/07, Quinn Weaver <quinn at fairpath.com> wrote:
> > Right.  And in this case, you'd do
> >
> > export PERL5LIB=/usr/local/FOO/lib/perl5 # bash syntax
> >
> > ... then Perl automatically searches under there for site_perl,
> > site_perl/5.8.0, and all those other weirdly named subdirs that
> > Perl uses to install things.

-- 
Live in a world of your own, but always welcome visitors.


More information about the SanFrancisco-pm mailing list