CPAN for non-root users

This recipe is based on Using CPAN with a non-root account by Jeremy Mates. It adds configuration settings for Module::Build and for newer versions of ExtUtils::MakeMaker. As with Jeremy's page, it configures CPAN for a non-root user and it does it from scratch: it is assumed there is no ~/.cpan directory and no previous MyConfig.pm. If there is, please make a backup.

  1. set these environment variables:
    MANPATHprepend with $HOME/perl/man
    PATHprepend with $HOME/perl/bin
    PERL5LIBset to $HOME/perl/lib/perl5
    FTP_PASSIVEset to '1' if needed for your firewall
  2. be sure, also in future, to load these environment variables before running cpan
  3. mkdir -p ~/.cpan/CPAN
  4. create textfile ~/.cpan/CPAN/MyConfig.pm with the contents from MyConfig.pm below
  5. replace HOMEDIR in MyConfig.pm with the full path to your home directory
  6. install the CPAN module: cpan CPAN, and accept 'yes' when asked to install required module Test::Harness
  7. start the cpan shell by typing cpan and choose your own mirrors by typing o conf init /urllist/
  8. install Bundle::CPAN
  9. type o conf makepl_arg INSTALL_BASE=HOMEDIR/perl, replacing HOMEDIR again

In the last step I am making use of the fact that Bundle::CPAN installs a newer version (6.31 or above) of ExtUtils::MakeMaker. See Module::Build::CookBook(3pm) for more information about INSTALL_BASE and --install_base.

MyConfig.pm
Copy this into ~/.cpan/CPAN/MyConfig.pm and replace HOMEDIR with the full path to your home directory:
$CPAN::Config = { 'applypatch' => q[], 'auto_commit' => q[1], 'build_cache' => q[100], 'build_dir' => q[HOMEDIR/.cpan/build], 'build_dir_reuse' => q[1], 'build_requires_install_policy' => q[ask/yes], 'bzip2' => q[/bin/bzip2], 'cache_metadata' => q[1], 'check_sigs' => q[0], 'colorize_debug' => q[black on_cyan], 'colorize_output' => q[0], 'colorize_print' => q[bold blue on_white], 'colorize_warn' => q[bold red on_white], 'commandnumber_in_prompt' => q[1], 'cpan_home' => q[HOMEDIR/.cpan], 'curl' => q[], 'dontload_hash' => { }, 'ftp' => q[/usr/bin/ftp], 'ftp_passive' => q[1], 'ftp_proxy' => q[], 'getcwd' => q[cwd], 'gpg' => q[/usr/bin/gpg], 'gzip' => q[/bin/gzip], 'histfile' => q[HOMEDIR/.cpan/histfile], 'histsize' => q[100], 'http_proxy' => q[], 'inactivity_timeout' => q[0], 'index_expire' => q[1], 'inhibit_startup_message' => q[0], 'keep_source_where' => q[HOMEDIR/.cpan/sources], 'load_module_verbosity' => q[v], 'lynx' => q[/usr/bin/lynx], 'make' => q[/usr/bin/make], 'make_arg' => q[], 'make_install_arg' => q[], 'make_install_make_command' => q[/usr/bin/make], 'makepl_arg' => q[PREFIX=~/perl/ SITELIBEXP=~/perl/lib/perl5 LIB=~/p +erl/lib/perl5 INSTALLMAN1DIR=~/perl/man/man1 INSTALLMAN3DIR=~/perl/ma +n/man3 INSTALLSITEMAN1DIR=~/perl/man/man1 INSTALLSITEMAN3DIR=~/perl/m +an/man3], 'mbuild_arg' => q[], 'mbuild_install_arg' => q[], 'mbuild_install_build_command' => q[./Build], 'mbuildpl_arg' => q[--install_base ~/perl], 'ncftp' => q[/usr/bin/ncftp], 'ncftpget' => q[], 'no_proxy' => q[], 'pager' => q[less], 'patch' => q[/usr/bin/patch], 'prefer_installer' => q[MB], 'prefs_dir' => q[HOMEDIR/.cpan/prefs], 'prerequisites_policy' => q[ask], 'proxy_user' => q[], 'scan_cache' => q[atstart], 'shell' => q[/bin/bash], 'show_unparsable_versions' => q[0], 'show_upload_date' => q[0], 'show_zero_versions' => q[0], 'tar' => q[/bin/tar], 'tar_verbosity' => q[none], 'term_is_latin' => q[0], 'term_ornaments' => q[1], 'test_report' => q[0], 'unzip' => q[/usr/bin/unzip], 'urllist' => [q[ftp://cpan.cs.utah.edu/pub/CPAN/]], 'use_sqlite' => q[0], 'wait_list' => [q[wait://ls6.informatik.uni-dortmund.de:1404]], 'wget' => q[/usr/bin/wget], 'yaml_load_code' => q[0], 'yaml_module' => q[YAML], }; 1; __END__