Installing perl modules locally

Dealing with CPAN has always felt a little weird. Today I found a nice shortcut for getting perl modules installed in a home directory, which is really useful for when you don’t have admin on the box, or if you simply prefer to keep your custom perl stuff all cinched up in a tidy homedir for ease of administration (or if you have to use custom modules on a machine with no dev tools; you can build them on a dev box and then just scp the entire ~/perl directory to where it’s needed).

LocalModInstall is a script that generates a modified Makefile for a perl module you wish to install, suitable for installing it into your home directory.

{42} andre@werk [work/perl-ldap-0.33] % perl ~/bin/
/usr/bin/perl Makefile.PL PREFIX=/Users/andre/perl \
INSTALLMAN1DIR=/Users/andre/perl/usr/share/man/man1 \
*** ExtUtils::AutoInstall version 0.59
*** Checking for dependencies...
[Core Features]
- Convert::ASN1   ...loaded. (0.19 >= 0.07)
[SASL authentication]
- Authen::SASL    ...loaded. (2.09 >= 2)
- Digest::MD5     ...loaded. (2.33)
- URI::ldap       ...loaded. (1.11 >= 1.1)
- IO::Socket::SSL ...missing. (would need 0.81)
==> Auto-install the 1 optional module(s) from CPAN? [n] n
[Read/Write DSML files]
- XML::SAX::Base  ...loaded. (1.04)
[Read/Write LDIF files]
- MIME::Base64    ...loaded. (3.05)
*** ExtUtils::AutoInstall configuration finished.
Writing Makefile for Net::LDAP

Don't forget to

  use lib

in your scripts (prior to any other "use" statements) or to set

  export PERL5LIB

in your shell (or shell configuration file) and to set

  export MANPATH

in your shell (or shell configuration file).

You would then ‘make’ and ‘make install’ like normal.

However, the ‘use lib’ suggestion that is supplied does not work in Mac OS X. The goods seem to be installed in ~/perl/lib/perl5/site_perl, which is not included in the suggested paths. Instead, I use:

use lib  qw(
/path/to/home/perl/lib/perl5/site_perl );

About dre

I like all kinds of food.
This entry was posted in development, OS X, OS X Server, scripts. Bookmark the permalink.

Leave a Reply