Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Monks,
I have my own development box at work (yes, I have root). The box is set up a certain way in regards to Perl and modules. I rather not mess with the @INC directories. I want to create my own directory under my home directory to install CPAN modules and test other ones. There is no CPAN module (or any other module that can establish outbound connections). Things are limited.

My question:
I want to know how I can tell these CPAN modules to install under my home directory when I am installing them. Should I edit the Makefile? (M::B is also not available)

Could I do something with PERL5LIB? Thanks

Replies are listed 'Best First'.
Re: Creating my own CPAN directory
by Zaxo (Archbishop) on Apr 18, 2006 at 03:39 UTC

    To use CPAN to install modules in a library in your home directory, you need to set up a private CPAN working directory in ~/.cpan. Place a CPAN configuration file under ~/.cpan/CPAN/MyConfig.pm with all the correct paths for your home, scripts, and library. Set up the PERL5LIB env. variable to look in that library for modules. If you're hosting cgi, arrange for the server to look there, too.

    That's all it takes. Here are a series of shell commands (mod version numbers and such) which will set it up for you in about five minutes:

    $ mkdir ~/.cpan $ mkdir ~/.cpan/CPAN $ cd ~/.cpan/CPAN $ cp /usr/lib/perl5/5.8.4/CPAN/Config.pm MyConfig.pm $ perl -pi -e's!/root/\.cpan!$ENV{HOME}/.cpan!' MyConfig.pm $ perl -pi -e'/makepl_arg/ && s!\]! PREFIX=$ENV{HOME}]!' MyConfig.pm $ echo "export PERL5LIB=${HOME}/lib/perl5/site_perl/5.8.4/i686-linux:$ +{HOME}/lib/perl5/site_perl/5.8.4" >> ~/.bash_profile $ source ~/.bash_profile $ cpan cpan shell -- CPAN exploration and modules installation (v1.7601) ReadLine support enabled cpan>
    I 've posted similar before, but it's always fresh.

    After Compline,
    Zaxo

Re: Creating my own CPAN directory
by saintmike (Vicar) on Apr 17, 2006 at 22:50 UTC
    1. Download tarball from http://search.cpan.org
    2. Install with
    perl Makefile.PL LIB=/home/mike/perl_modules make make test make install

    3. Use with
    use lib '/home/mike/perl_modules'; use Some::Module;
Re: Creating my own CPAN directory
by salva (Canon) on Apr 17, 2006 at 22:48 UTC
    For modules using ExtUtils::MakeMaker:
    perl Makefile.PL PREFIX=/foo/bar

    BTW, you can use CPAN::Mini to create a small CPAN mirror in some computer with full Internet access, burn it into a CD or DVD and then configure the CPAN module on your development machine to use that CD as its CPAN "mirror".

Re: Creating my own CPAN directory
by rinceWind (Monsignor) on Apr 18, 2006 at 10:57 UTC

    I'm doing quite a lot of this at the moment, and on this installation I don't have root. In my case, there are extra complications, including multi platform code bases (Solaris and Windows) and some Clearcase voodoo involved.

    I use a combination of PREFIX= and LIB= which others have mentioned. LIB= gives me a flatish directory structure that I can point my PERL5LIB to, and PREFIX deals with all the other files that make install installs. It is important to set PERL5LIB to be the lib directory if you are installing multiple modules with dependencies, as indeed on your final run environment.

    When it comes to Module::Build, the mechanism is cleaner - you should just be able to set install_base= to the same place as you would set PREFIX= to. Module::Build does use its own install mechanism, and yes, you can put this under your own CPAN directory tree in PERL5LIB's path list.

    Hope this helps

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)