Error message

Notice: Undefined index: localized_options in menu_navigation_links() (line 1861 of /net/council/home/www/drupal/includes/

Pre-configuring CPAN for non-interactive installation


I do a lot of linux and windows automated system building. Automated system building requires many commands along the way to be 'silenced' and 'assume default' answers for questions that during a normal, single system build you can answer easily along the way. One that has gotten me over the years is the need for you to initialize CPAN before you can use 'cpan -i' to install packages relatively silently in most cases. Once, you configure this one time (each login user must configure) you never have to answer the default set of questions again. I've searched repeatedly, hitting dead-ends and half-answered suggestions of 'inserting a static CPAN::Config array' and other hints to leverage perl libs to handle this. Then, last week, I stumbled across something that may have been so painfully obvious that this is the reason I've never found an answer on the internet... 'it's just like everything else, it's a static config file'. So, is it really this easy? My initial tests seem to answer yes.

In Debian, all you have to do is find a way to pre-configure/populate the file:

An example of a possible file (that I have used) is here, I can't see anything security crazy I'm giving away by posting this.
# This is's systemwide configuration file. This file provides
# defaults for users, and the values can be changed in a per-user
# configuration file. The user-config file is being looked for as
# /root/.cpan/CPAN/

$CPAN::Config = {
'applypatch' => q[],
'auto_commit' => q[0],
'build_cache' => q[100],
'build_dir' => q[/root/.cpan/build],
'build_dir_reuse' => q[0],
'build_requires_install_policy' => q[ask/yes],
'bzip2' => q[],
'cache_metadata' => q[1],
'check_sigs' => q[0],
'commandnumber_in_prompt' => q[1],
'connect_to_internet_ok' => q[1],
'cpan_home' => q[/root/.cpan],
'curl' => q[],
'ftp' => q[],
'ftp_passive' => q[1],
'ftp_proxy' => q[],
'getcwd' => q[cwd],
'gpg' => q[/usr/bin/gpg],
'gzip' => q[/bin/gzip],
'halt_on_failure' => q[0],
'histfile' => q[/root/.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[/root/.cpan/sources],
'load_module_verbosity' => q[v],
'lynx' => q[],
'make' => q[],
'make_arg' => q[],
'make_install_arg' => q[],
'make_install_make_command' => q[],
'makepl_arg' => q[INSTALLDIRS=site],
'mbuild_arg' => q[],
'mbuild_install_arg' => q[],
'mbuild_install_build_command' => q[./Build],
'mbuildpl_arg' => q[--installdirs site],
'ncftp' => q[],
'ncftpget' => q[],
'no_proxy' => q[],
'pager' => q[/bin/more],
'patch' => q[],
'perl5lib_verbosity' => q[v],
'prefer_installer' => q[MB],
'prefs_dir' => q[/root/.cpan/prefs],
'prerequisites_policy' => q[ask],
'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[v],
'term_is_latin' => q[1],
'term_ornaments' => q[1],
'test_report' => q[0],
'trust_test_report_history' => q[0],
'unzip' => q[],
'urllist' => [],
'use_sqlite' => q[0],
'wget' => q[/usr/bin/wget],
'yaml_load_code' => q[0],
'yaml_module' => q[YAML],


Remember that you must have build-essentials package installed because perl uses make and such.

To port this idea to other Linux distros you should just have to locate a primary path that perl uses (google finding perl default path or something) and drop the file where it should be found before it finds other ones.

Perl PATH info here: which shows

perl -le 'print foreach @INC')

which is actually what I used to start me down this road.

And one final note perhaps worth metioning, this does not deal with:

CPAN: Automatically install dependencies without confirmation

This only deals with silencing the initial request to configure CPAN. So, there's a nice blog here that may be what you're looking for if cpan -i is still prompting about dependencies and such.