User CPAN instalation



Running CPAN shell as a normal user

Execute in the shelll
      $ perl -MCPAN -e shell
If this gives an error stating:
    Your configuration suggests "/root/.cpan" as your
CPAN.pm working directory. I could not create this directory due
to this error: mkdir /root/.cpan: Permission denied at /usr/lib/perl5/5.6.1/CPAN.pm line 499

Please make sure the directory exists and is writable.
Execute the following procedure (it worked for me, though I am not sure if all steps are necessary):
  1. Create a directory for the perl modules in your HOME
          $ mkdir ~/perl5lib
  2. Create ~/.cpan and ~/.cpan/CPAN directories:
          $ mkdir ~/.cpan
    $ mkdir ~/.cpan/CPAN
  3. Create a Config.pm for the CPAN module with $CPAN::Config empty
          $ echo "\$CPAN::Config = {}"> ~/.cpan/CPAN/MyConfig.pm
  4. Execute again:
          $ perl -MCPAN -e shell
    This time (if all goes well) it will prompt you for the empty fields in $CPAN::Config.

  5. It is OK to accept the default values until it asks you for the parameters for the Makefile.pl
          Parameters for the 'perl Makefile.PL' command?
    Typical frequently used settings:

    POLLUTE=1 increasing backwards compatibility
    LIB=~/perl non-root users (please see manual for more hints)
    You should then answer with the following line:
          PREFIX=~/perl5lib/ LIB=~/perl5lib/lib INSTALLMAN1DIR=~/perl5lib/man1 INSTALLMAN3DIR=~/perl5lib/man3
    This will add the parameters for your user Makefile.
    This will enable installations of Modules (.pm) and compile code (.so) in ~/perl5lib/ (more accurately in a subdirectory named after the architecture of your machine). Files for the manual of the modules will also be installled in the specified directories.

  6. Finish the CPAN configuration by answering all other questions (ex.: http_proxy?http://your_proxy.yourdomain).
  7. Set the environment variables for the perl lib path and the manpath. Using bash you should do something like
          export PERL5LIB=${PERL5LIB}:~/perl5lib
    export MANPATH=~/perl5lib

  8. You should add the environment variable settings to your profile file (in bash ~/.bash_profile)

By this time all should be set to use correctly the CPAN module by invoking:
      $ perl -MCPAN -e shell
You should consult the CPAN documentation if you have any doubt.