Austin Moore
Austin Moore

Reputation: 1412

Installing Perl modules and dependencies with non-root and without CPAN

I have been writing Perl scripts for my work and the machine that I have been given to work on makes installing Perl modules difficult:

Usually, when I want to install a module, I put in a request and I have to wait a day or two before it gets installed. I know that nobody would have a problem with me installing them myself, so to save everyone's time and my sanity I would like to install them myself. It's just an issue of how to best do that. I have talked to various people and they said to use an RPM to install them (to get around not having gcc). However, when trying to install modules from RPMs, it does not handle the dependencies so I would manually need to handle the dependencies, which could take a while.

How can I best install Perl modules with these limitations?

Upvotes: 3

Views: 1546

Answers (2)

ikegami
ikegami

Reputation: 385647

On a similar machine with a similarly built Perl, install the module(s) using

mkdir ~/foo
cpan
o conf makepl_arg 'PREFIX=~/foo LIB=~/foo/lib/perl5'
o conf mbuildpl_arg '--prefix ~/foo --lib ~/foo/lib/perl5'
install Some::Module

As long as you don't do o conf commit, the configuration change will be temporary, so don't do that.

Copy ~/foo over, and set env var PERL5LIB to include the LIB directory. You can merge a newer ~/foo into an older one to add new modules.

This won't install any non-Perl libraries on which the modules depend.

Upvotes: 3

Greg Bacon
Greg Bacon

Reputation: 139451

See also How do I keep my own module/library directory? in section 8 of the Perl FAQ.

When you build modules, tell Perl where to install the modules.

For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:

perl Makefile.PL INSTALL_BASE=/mydir/perl

For Build.PL-based distributions, use the --install_base option:

perl Build.PL --install_base /mydir/perl

INSTALL_BASE tells these tools to put your modules into /mydir/perl/lib/perl5. See How do I add a directory to my include path (@INC) at runtime? for details on how to run your newly installed modules.

There is one caveat with INSTALL_BASE, though, since it acts differently from the PREFIX and LIB settings that older versions of ExtUtils::MakeMaker advocated. INSTALL_BASE does not support installing modules for multiple versions of Perl or different architectures under the same directory. You should consider whether you really want that and, if you do, use the older PREFIX and LIB settings. See the ExtUtils::Makemaker documentation for more details.

Upvotes: 0

Related Questions