User Tools

Site Tools




To install Modules Locally

local::lib enables you to install modules into a specified directory,
without requiring root or administrator access. See the bootstrapping technique for how to get started.
You can create a directory per user/project/company and deploy to other servers,
by copying the directory (as long as you are on the same operating system).

CPAN Local::lib
But you can also manually do it.

First export your username

 export username=ketan

<note warning>Still you have to modify / change “$username” manually at many places</note>

create the .cpan directories

 mkdir $HOME/.cpan/
 mkdir $HOME/.cpan/CPAN/
 # This is so it ignores the global CPAN config
 echo "\$CPAN::Config->{cpan_home}='/home/$username/.cpan';" > /home/$username/.cpan/CPAN/

Then Execute a CPAN shell

 perl -MCPAN -e shell

Then when in the shell type:

 o conf init

<note>to reconfigure CPAN, replace all */root/.cpan/* with /home/$username/.cpan/*</note>

change the makepl_arg so it should look like.

| /home/$username/.cpan/CPAN/
 'makepl_arg' => q[INSTALLDIRS=site PREFIX=/home/$username/perl/],

Finally the env variable PERL5LIB needs to point to the new module installation paths:

 export PERL5LIB="/home/$username/perl/share/perl/custom_lib/:/home/$username/perl/lib/perl/custom_lib/";

and then you should be able to use CPAN to install modules.

I then modified following file

| ~/.bashrc
export PERL_LOCAL_LIB_ROOT="/home/$username/perl";
export PERL_MB_OPT="--install_base /home/$username/perl";
export PERL_MM_OPT="INSTALL_BASE=/home/$username/perl";
export PERL5LIB="/home/$username/perl/share/perl/custom_lib/:/home/$username/perl/lib/perl/custom_lib/";
export PATH="/home/$username/perl/bin:$PATH";
usage_on_fly.txt · Last modified: 2012/03/28 14:34 by k2patel