CPAN module local installation question

CPAN module local installation question

am 12.07.2006 10:49:30 von Ronald Fischer

It's the first time that I am doing a *local* install of a CPAN
module, and promptly stumbled over a problem:

Using /tmp/foo as a destination directory for playing around,
Following the documentation on

http://search.cpan.org/~jhi/perl-5.8.0/pod/perlmodinstall.po d)

(I mention this because, as you will see below, it might be
that this documentation is incorrect about local installation),
I did:

perl Makefile.PL PREFIX=/tmp/foo
make
make install

which worked fine and produced, as expected:

$ du /tmp/foo
68 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List/MoreUtils
72 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List
76 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto
24 /tmp/foo/lib/site_perl/5.8.3/i686-linux/List
104 /tmp/foo/lib/site_perl/5.8.3/i686-linux
108 /tmp/foo/lib/site_perl/5.8.3
112 /tmp/foo/lib/site_perl
8 /tmp/foo/lib/5.8.3/i686-linux
12 /tmp/foo/lib/5.8.3
128 /tmp/foo/lib
28 /tmp/foo/man/man3
32 /tmp/foo/man
164 /tmp/foo

Also, the module was installed at the expected place:

$ find /tmp/foo -name '*pm'
/tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm

Now the aforementioned CPAN page says:

'Type
perl Makefile.PL PREFIX=/my/perl_directory
to install it locally. (Remember that if you do this, you'll have to put
use lib "/my/perl_directory"; near the top of the program that is to use
this module.'

So I tried the following to test my installation:

$ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
/usr/local/perl5.8.3/lib/5.8.3/i686-linux /usr/local/perl5.8.3/lib/5.8.3
/usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
/usr/local/perl5.8.3/lib/site_perl/5.8.3
/usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

Of course if I do the test in the following way:

perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
List::MoreUtils;'

it works, but from what the CPAN documentation site suggests, it
should be sufficient to specify in @INC the parent of the lib directory.

Did I do something wrong? Is this an error in the documentation on the
CPAN site?

Ronald


--
Ronald Fischer
Posted via http://www.newsoffice.de/

Re: CPAN module local installation question

am 12.07.2006 11:59:40 von Stephan Titard

Ronald Fischer escribió:
> It's the first time that I am doing a *local* install of a CPAN
> module, and promptly stumbled over a problem:
>
> Using /tmp/foo as a destination directory for playing around,
> Following the documentation on
>
> http://search.cpan.org/~jhi/perl-5.8.0/pod/perlmodinstall.po d)
>
> (I mention this because, as you will see below, it might be
> that this documentation is incorrect about local installation),
> I did:
>
> perl Makefile.PL PREFIX=/tmp/foo
> make
> make install
>
> which worked fine and produced, as expected:
>
> $ du /tmp/foo
> 68 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List/MoreUtils
> 72 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List
> 76 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto
> 24 /tmp/foo/lib/site_perl/5.8.3/i686-linux/List
> 104 /tmp/foo/lib/site_perl/5.8.3/i686-linux
> 108 /tmp/foo/lib/site_perl/5.8.3
> 112 /tmp/foo/lib/site_perl
> 8 /tmp/foo/lib/5.8.3/i686-linux
> 12 /tmp/foo/lib/5.8.3
> 128 /tmp/foo/lib
> 28 /tmp/foo/man/man3
> 32 /tmp/foo/man
> 164 /tmp/foo
>
> Also, the module was installed at the expected place:
>
> $ find /tmp/foo -name '*pm'
> /tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm
>
> Now the aforementioned CPAN page says:
>
> 'Type
> perl Makefile.PL PREFIX=/my/perl_directory
> to install it locally. (Remember that if you do this, you'll have to put
> use lib "/my/perl_directory"; near the top of the program that is to use
> this module.'
>
> So I tried the following to test my installation:
>
> $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
> Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
> /usr/local/perl5.8.3/lib/5.8.3/i686-linux /usr/local/perl5.8.3/lib/5.8.3
> /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
> /usr/local/perl5.8.3/lib/site_perl/5.8.3
> /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
> BEGIN failed--compilation aborted at -e line 1.
>
> Of course if I do the test in the following way:
>
> perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
> List::MoreUtils;'
>
> it works, but from what the CPAN documentation site suggests, it
> should be sufficient to specify in @INC the parent of the lib directory.
>
> Did I do something wrong? Is this an error in the documentation on the
> CPAN site?
>
> Ronald
>
>
does it help to include the lib subdir too?
I mean: "/tmp/foo/lib"
--stephan

Re: CPAN module local installation question

am 12.07.2006 12:36:32 von ro.naldfi.scher

Stephan Titard schrieb:
> Ronald Fischer escribi=F3:
> > $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
> > Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
> > /usr/local/perl5.8.3/lib/5.8.3/i686-linux /usr/local/perl5.8.3/lib/5.8.3
> > /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
> > /usr/local/perl5.8.3/lib/site_perl/5.8.3
> > /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
> > BEGIN failed--compilation aborted at -e line 1.
> >
> > Of course if I do the test in the following way:
> >
> > perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
> > List::MoreUtils;'
> >
> > it works, but from what the CPAN documentation site suggests, it
> > should be sufficient to specify in @INC the parent of the lib directory.
> does it help to include the lib subdir too?
> I mean: "/tmp/foo/lib"

No, doesn't work either.

Interestingly, @INC also contains by defaul not, say,
/usr/local/perl5.8.3,
put lists all its subdirectories explitily.

Ronald

Re: CPAN module local installation question

am 12.07.2006 14:07:49 von mumia.w.18.spam+nospam.usenet

On 07/12/2006 04:59 AM, Stephan Titard wrote:
> Ronald Fischer escribió:
>> It's the first time that I am doing a *local* install of a CPAN
>> module, and promptly stumbled over a problem:
>>
>> Using /tmp/foo as a destination directory for playing around,
>> Following the documentation on
>>
>> http://search.cpan.org/~jhi/perl-5.8.0/pod/perlmodinstall.po d)
>>
>> (I mention this because, as you will see below, it might be
>> that this documentation is incorrect about local installation),
>> I did:
>>
>> perl Makefile.PL PREFIX=/tmp/foo
>> make
>> make install
>>
>> which worked fine and produced, as expected:
>>
>> $ du /tmp/foo
>> 68 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List/MoreUtils
>> 72 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List
>> 76 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto
>> 24 /tmp/foo/lib/site_perl/5.8.3/i686-linux/List
>> 104 /tmp/foo/lib/site_perl/5.8.3/i686-linux
>> 108 /tmp/foo/lib/site_perl/5.8.3
>> 112 /tmp/foo/lib/site_perl
>> 8 /tmp/foo/lib/5.8.3/i686-linux
>> 12 /tmp/foo/lib/5.8.3
>> 128 /tmp/foo/lib
>> 28 /tmp/foo/man/man3
>> 32 /tmp/foo/man
>> 164 /tmp/foo
>>
>> Also, the module was installed at the expected place:
>>
>> $ find /tmp/foo -name '*pm'
>> /tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm
>>
>> Now the aforementioned CPAN page says:
>>
>> 'Type
>> perl Makefile.PL PREFIX=/my/perl_directory
>> to install it locally. (Remember that if you do this, you'll have to
>> put use lib "/my/perl_directory"; near the top of the program that is
>> to use this module.'
>>
>> So I tried the following to test my installation:
>>
>> $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
>> Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
>> /usr/local/perl5.8.3/lib/5.8.3/i686-linux
>> /usr/local/perl5.8.3/lib/5.8.3
>> /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
>> /usr/local/perl5.8.3/lib/site_perl/5.8.3
>> /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
>> BEGIN failed--compilation aborted at -e line 1.
>>
>> Of course if I do the test in the following way:
>>
>> perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
>> List::MoreUtils;'
>>
>> it works, but from what the CPAN documentation site suggests, it
>> should be sufficient to specify in @INC the parent of the lib directory.
>>
>> Did I do something wrong? Is this an error in the documentation on the
>> CPAN site?
>>
>> Ronald
>>
>>
> does it help to include the lib subdir too?
> I mean: "/tmp/foo/lib"
> --stephan

"Perldoc perlmodinstall" suggests that only /tmp/foo is
necessary when, in fact, /tmp/foo/lib is required, e.g.

$ perl -Mlib=/tmp/foo -MList::MoreUtils -e 1

fails when perlmodinstall suggests it should succeed.
Instead you must do this:

$ perl -Mlib=/tmp/foo/lib -MList::MoreUtils -e 1

IMO (in my opinion), it's a document bug in
perlmodinstall.pod, but it's not as grand as what Mr.
Fischer was thinking.

Re: CPAN module local installation question

am 12.07.2006 15:05:29 von Sherm Pendley

Ronald Fischer writes:

> Also, the module was installed at the expected place:
>
> $ find /tmp/foo -name '*pm'
> /tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm
>
> Now the aforementioned CPAN page says:
>
> 'Type
> perl Makefile.PL PREFIX=/my/perl_directory
> to install it locally. (Remember that if you do this, you'll have to
> put use lib "/my/perl_directory"; near the top of the program that is
> to use this module.'
>
> So I tried the following to test my installation:
>
> $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
> Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
> /usr/local/perl5.8.3/lib/5.8.3/i686-linux
> /usr/local/perl5.8.3/lib/5.8.3
> /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
> /usr/local/perl5.8.3/lib/site_perl/5.8.3
> /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
> BEGIN failed--compilation aborted at -e line 1.
>
> Of course if I do the test in the following way:
>
> perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
> List::MoreUtils;'
>
> it works, but from what the CPAN documentation site suggests, it
> should be sufficient to specify in @INC the parent of the lib directory.

You should be able to "use lib '/tmp/foo/lib/site_perl';" - the version
and architecture directory should be added automagically by the lib pragma.

Using PREFIX changes the base directory, but doesn't change the layout of the
directories under it. That layout still makes a distinction between Core and
CPAN modules, even when you're only installing CPAN modules.

> Did I do something wrong? Is this an error in the documentation on the
> CPAN site?

I suppose it's technically correct, in that a module might be configured to
install in the directory for core modules. It's certainly misleading though,
and doesn't apply to the most common case.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Re: CPAN module local installation question

am 12.07.2006 21:14:30 von mumia.w.18.spam+nospam.usenet

On 07/12/2006 07:07 AM, Mumia W. wrote:
> On 07/12/2006 04:59 AM, Stephan Titard wrote:
>> Ronald Fischer escribió:
>>> It's the first time that I am doing a *local* install of a CPAN
>>> module, and promptly stumbled over a problem:
>>>
>>> Using /tmp/foo as a destination directory for playing around,
>>> Following the documentation on
>>>
>>> http://search.cpan.org/~jhi/perl-5.8.0/pod/perlmodinstall.po d)
>>>
>>> (I mention this because, as you will see below, it might be
>>> that this documentation is incorrect about local installation),
>>> I did:
>>>
>>> perl Makefile.PL PREFIX=/tmp/foo
>>> make
>>> make install
>>>
>>> which worked fine and produced, as expected:
>>>
>>> $ du /tmp/foo
>>> 68 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List/MoreUtils
>>> 72 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto/List
>>> 76 /tmp/foo/lib/site_perl/5.8.3/i686-linux/auto
>>> 24 /tmp/foo/lib/site_perl/5.8.3/i686-linux/List
>>> 104 /tmp/foo/lib/site_perl/5.8.3/i686-linux
>>> 108 /tmp/foo/lib/site_perl/5.8.3
>>> 112 /tmp/foo/lib/site_perl
>>> 8 /tmp/foo/lib/5.8.3/i686-linux
>>> 12 /tmp/foo/lib/5.8.3
>>> 128 /tmp/foo/lib
>>> 28 /tmp/foo/man/man3
>>> 32 /tmp/foo/man
>>> 164 /tmp/foo
>>>
>>> Also, the module was installed at the expected place:
>>>
>>> $ find /tmp/foo -name '*pm'
>>> /tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm
>>>
>>> Now the aforementioned CPAN page says:
>>>
>>> 'Type
>>> perl Makefile.PL PREFIX=/my/perl_directory
>>> to install it locally. (Remember that if you do this, you'll have to
>>> put use lib "/my/perl_directory"; near the top of the program that is
>>> to use this module.'
>>>
>>> So I tried the following to test my installation:
>>>
>>> $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
>>> Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
>>> /usr/local/perl5.8.3/lib/5.8.3/i686-linux
>>> /usr/local/perl5.8.3/lib/5.8.3
>>> /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
>>> /usr/local/perl5.8.3/lib/site_perl/5.8.3
>>> /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
>>> BEGIN failed--compilation aborted at -e line 1.
>>>
>>> Of course if I do the test in the following way:
>>>
>>> perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
>>> List::MoreUtils;'
>>>
>>> it works, but from what the CPAN documentation site suggests, it
>>> should be sufficient to specify in @INC the parent of the lib directory.
>>>
>>> Did I do something wrong? Is this an error in the documentation on the
>>> CPAN site?
>>>
>>> Ronald
>>>
>>>
>> does it help to include the lib subdir too?
>> I mean: "/tmp/foo/lib"
>> --stephan
>
> "Perldoc perlmodinstall" suggests that only /tmp/foo is necessary when,
> in fact, /tmp/foo/lib is required, e.g.
>
> $ perl -Mlib=/tmp/foo -MList::MoreUtils -e 1
>
> fails when perlmodinstall suggests it should succeed. Instead you must
> do this:
>
> $ perl -Mlib=/tmp/foo/lib -MList::MoreUtils -e 1
>

I was wrong. This works:

$ perl -Mlib=/tmp/foo/lib/perl -MList::MoreUtils -e 1

> IMO (in my opinion), it's a document bug in perlmodinstall.pod, but it's
> not as grand as what Mr. Fischer was thinking.
>

Now I don't know what to think. For me, MoreUtils.pm
was put into a different location:

(inside /tmp/foo)
> $ find . -name '*.pm'
> ./lib/perl/5.8.4/List/MoreUtils.pm

?

Re: CPAN module local installation question

am 13.07.2006 09:40:50 von ro.naldfi.scher

Sherm Pendley schrieb:
> Ronald Fischer writes:
> > $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
> > Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
> > /usr/local/perl5.8.3/lib/5.8.3/i686-linux
> > /usr/local/perl5.8.3/lib/5.8.3
> > /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
> > /usr/local/perl5.8.3/lib/site_perl/5.8.3
> > /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
> > BEGIN failed--compilation aborted at -e line 1.
> >
> > Of course if I do the test in the following way:
> >
> > perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
> > List::MoreUtils;'
> >
> > it works, but from what the CPAN documentation site suggests, it
> > should be sufficient to specify in @INC the parent of the lib directory.
>
> You should be able to "use lib '/tmp/foo/lib/site_perl';" - the version
> and architecture directory should be added automagically by the lib pragma.

It is correct, that *this* works, while, for example, "use lib
'/tmp/foo/lib" is
not sufficient.

Given that the complete path to the module is

/tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm

I wonder how the search algorithm of "use lib" is implemente, that it
can find
the directory "List" two levels down from site_perl, but not three
levels down
from lib.

I could understand if the implementors of Perl require the search path
to list
extensively all directories explicitly, which can contain modules
( /tmp/foo/lib/site_perl/5.8.3/i686-linux in my example). I could also
understand a design decision which states that the lib directory needs
to be stated (because the layout below lib is kind of "known structure"
to perl), i.e. that use lib "/tmp/foo/lib" or even /tmp/foo would be
sufficient.
But to require that the library path needs to be specified down to the
site_perl directory, seems to be such an arbitrary decision, that I
suspect
this is a bug in Perl (in the sense that it is not what the implementor
originally had intended).

Now if we just could get an authoritative response to this question...

Ronald

Re: CPAN module local installation question

am 13.07.2006 16:50:20 von Sherm Pendley

ro.naldfi.scher@gmail.com writes:

> Sherm Pendley schrieb:
>> Ronald Fischer writes:
>> > $ perl -e 'use lib "/tmp/foo"; use List::MoreUtils;'
>> > Can't locate List/MoreUtils.pm in @INC (@INC contains: /tmp/foo
>> > /usr/local/perl5.8.3/lib/5.8.3/i686-linux
>> > /usr/local/perl5.8.3/lib/5.8.3
>> > /usr/local/perl5.8.3/lib/site_perl/5.8.3/i686-linux
>> > /usr/local/perl5.8.3/lib/site_perl/5.8.3
>> > /usr/local/perl5.8.3/lib/site_perl .) at -e line 1.
>> > BEGIN failed--compilation aborted at -e line 1.
>> >
>> > Of course if I do the test in the following way:
>> >
>> > perl -e 'use lib "/tmp/foo/lib/site_perl/5.8.3/i686-linux"; use
>> > List::MoreUtils;'
>> >
>> > it works, but from what the CPAN documentation site suggests, it
>> > should be sufficient to specify in @INC the parent of the lib directory.
>>
>> You should be able to "use lib '/tmp/foo/lib/site_perl';" - the version
>> and architecture directory should be added automagically by the lib pragma.
>
> It is correct, that *this* works, while, for example, "use lib
> '/tmp/foo/lib" is
> not sufficient.
>
> Given that the complete path to the module is
>
> /tmp/foo/lib/site_perl/5.8.3/i686-linux/List/MoreUtils.pm
>
> I wonder how the search algorithm of "use lib" is implemente, that it
> can find
> the directory "List" two levels down from site_perl, but not three
> levels down
> from lib.

It's not really searching at all. First it checks to see if the specified
directory exists, and if so adds it to @INC. Then it appends the version
number of the currently-running Perl, and repeats, and then again with the
architecture.

Imagine that site_perl/ is on a network-mounted volume, and accessible from
a variety of machine types all running different versions of Perl. You could
still use a single 'use lib' statement in a script that needs to run on all
those machines, and Perl would sort out which module each machine needed to
load.

> understand a design decision which states that the lib directory needs
> to be stated (because the layout below lib is kind of "known structure"
> to perl)

The layout below lib is *not* a known structure, it's just the default. The
only known structure is the version/arch subdirectories. On Mac OS X, for
instance, CPAN modules are found in /Library/Perl.

> But to require that the library path needs to be specified down to the
> site_perl directory, seems to be such an arbitrary decision, that I
> suspect this is a bug in Perl

Suspecting that anything for which you don't understand the rationale must
be bug seems quite arrogant to me.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net

Re: CPAN module local installation question

am 17.07.2006 12:11:03 von ro.naldfi.scher

Sherm Pendley schrieb:
> ro.naldfi.scher@gmail.com writes:
> Imagine that site_perl/ is on a network-mounted volume, and accessible from
> a variety of machine types all running different versions of Perl. You could
> still use a single 'use lib' statement in a script that needs to run on all
> those machines, and Perl would sort out which module each machine needed to
> load.

I understand. This makes sense indeed.

> > But to require that the library path needs to be specified down to the
> > site_perl directory, seems to be such an arbitrary decision, that I
> > suspect this is a bug in Perl
>
> Suspecting that anything for which you don't understand the rationale must
> be bug seems quite arrogant to me.

Point taken, especially as I see now that the decision was not
arbitrary at all (though hard to guess without explanation:-)

So maybe the only thing which should be done is to correct the
installation
instructions on CPAN, so that people know how to write a correct use
lib
for those cases where modules are not installed in the default
locations.

Ronald