How do I specify @INC during CPAN module installation?

E

ethandbrown

Hi Group--

I'm having trouble deploying some code on my webhost's server because
of module incompatibilities. I'm able to install the latest CPAN
modules in my own account space, but I'm running into compatibility
issues because the default modules installed in the system directories
can be out of date with respect to the newer modules I'm installing.

I'd like to cleanly install the most current set of modules in my own
account space, but I'm not sure how to tell the CPAN module to consider
only my module path during its builds so that the newest dependent
modules are also installed (and the system modules are ignored). In my
own programs I can just set:

@INC = ("/home/myaccount/myperllibs/lib");

but I'm unclear as to how to do this while running "perl -MCPAN -e
shell"

I've reviewed the CPAN docs and saw "How to install modules in your own
space", but they don't make mention of specifying a custom "@INC" while
doing it (or I just missed it).

Help is appreciated. Thanks,

--Ethan
 
E

ethandbrown

Sherm said:
You can prepend to @INC with the -I switch, like this:

perl -I/home/myaccount/myperllibs/lib -MCPAN -e shell

You could also set the PERL5LIB environment variable. The syntax for that
is dependent on the shell you're using - for bash it would be:

export PERL5LIB=/home/myaccount/myperllibs/lib

Have a look at "perldoc perlrun" for details.

sherm--

Hi Sherm--

Thanks for the quick response. Unfortunately, both of these
suggestions just add another entry into the @INC list, rather than
removing the system module directories. Here's an example dump after
using the "export" method:
---------------------------------------------------
ethan@strider:~$ export PERL5LIB=/home/myaccount/myperllibs/lib
ethan@strider:~$ perl -e 'print "@INC\n"'
/home/myaccount/myperllibs/lib /etc/perl /usr/local/lib/perl/5.8.7
/usr/local/share/perl/5.8.7 /usr/lib/perl5 /usr/share/perl5
/usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .
ethan@strider:~$
---------------------------------------------------

To reiterate my original request, I need the CPAN build process to
ignore the default system module directories.

Again, thank you for your time in replying to my request.

--Ethan
 
J

J.D. Baldwin

In the previous article said:
I'd like to cleanly install the most current set of modules in my
own account space, but I'm not sure how to tell the CPAN module to
consider only my module path during its builds so that the newest
dependent modules are also installed (and the system modules are
ignored). In my own programs I can just set:

@INC = ("/home/myaccount/myperllibs/lib");

but I'm unclear as to how to do this while running "perl -MCPAN -e
shell"

Well, there's always

perl -MCPAN -e 'BEGIN { @INC = ("/home/myaccount/myperllibs/lib") } shell'

but replacing all of @INC is (as pointed out elsewhere) a Bad Idea.
I've reviewed the CPAN docs and saw "How to install modules in your
own space", but they don't make mention of specifying a custom
"@INC" while doing it (or I just missed it).

When dealing routinely with non-system modules, I set and export
PERL5LIB like so (sh-like shell):

PERL5LIB="/home/myaccount/myperllibs/lib"
export PERL5LIB
perl -M...<whatever>

Also see "use lib" in, for example,

http://www.webreference.com/programming/perl/modules/3.html
 
B

Ben Morrow

Quoth "[email protected] said:
Hi Group--

I'm having trouble deploying some code on my webhost's server because
of module incompatibilities. I'm able to install the latest CPAN
modules in my own account space, but I'm running into compatibility
issues because the default modules installed in the system directories
can be out of date with respect to the newer modules I'm installing.

I'd like to cleanly install the most current set of modules in my own
account space, but I'm not sure how to tell the CPAN module to consider
only my module path during its builds so that the newest dependent
modules are also installed (and the system modules are ignored). In my
own programs I can just set:

@INC = ("/home/myaccount/myperllibs/lib");

but I'm unclear as to how to do this while running "perl -MCPAN -e
shell"

Well,

perl -e'BEGIN { @INC = ("...") } use CPAN; shell'

is the answer to your question as asked, but I believe you have received
a more useful solution to your problem (use the 'upgrade' command)
downthread. Apart from anything else, the above will almost certainly
fail due to not being able to find CPAN.pm itself.

Ben
 
E

ethandbrown

Ben said:
Well,

perl -e'BEGIN { @INC = ("...") } use CPAN; shell'

is the answer to your question as asked, but I believe you have received
a more useful solution to your problem (use the 'upgrade' command)
downthread. Apart from anything else, the above will almost certainly
fail due to not being able to find CPAN.pm itself.

Ben

Thanks Ben. I was planning on installing the latest CPAN in my
workspace first :).

I'll try it the "right" way, with 'upgrade' and see how that works out.
Thanks to all for their time and patience in responding to my
question.

--Ethan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top