This shows you the differences between two versions of the page.
usage_on_fly [2012/02/23 18:26] k2patel [To install Modules Locally] |
usage_on_fly [2020/08/10 02:35] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Perl ====== | ||
- | |||
- | ===== CPAN ===== | ||
- | |||
- | ==== To install Modules Locally ==== | ||
- | Best way to install local module is to install module "local::lib".\\ | ||
- | [[http://search.cpan.org/~apeiron/local-lib/ | CPAN Local::lib ]]\\ | ||
- | But you can also manually do it. | ||
- | |||
- | **First export your username** | ||
- | |||
- | <code bash> | ||
- | export username=ketan | ||
- | </code> | ||
- | |||
- | <note warning>Still you have to modify / change "$username" manually at many places</note> | ||
- | |||
- | **create the .cpan directories** | ||
- | |||
- | <code oobas> | ||
- | 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/MyConfig.pm | ||
- | </code> | ||
- | Then Execute a CPAN shell | ||
- | |||
- | <code oobas> | ||
- | perl -MCPAN -e shell | ||
- | OR | ||
- | cpan | ||
- | </code> | ||
- | Then when in the shell type: | ||
- | |||
- | <code oobas> | ||
- | o conf init | ||
- | </code> | ||
- | <note>to reconfigure CPAN, replace all */root/.cpan/* with /home/$username/.cpan/*</note> | ||
- | |||
- | change the makepl_arg so it should look like. | ||
- | |||
- | <code bash | /home/$username/.cpan/CPAN/MyConfig.pm> | ||
- | 'makepl_arg' => q[INSTALLDIRS=site PREFIX=/home/$username/perl/], | ||
- | </code> | ||
- | Finally the env variable PERL5LIB needs to point to the new module installation paths: | ||
- | |||
- | <code oobas> | ||
- | export PERL5LIB="/home/$username/perl/share/perl/custom_lib/:/home/$username/perl/lib/perl/custom_lib/"; | ||
- | </code> | ||
- | and then you should be able to use CPAN to install modules. | ||
- | |||
- | I then modified following file | ||
- | |||
- | <code bash | ~/.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"; | ||
- | </code> | ||