Search code examples
perlcpancpanm

Is there a way to configure the default mirror for App::cpanminus (cpanm)?


I am aware you can easily configure cpan to use a specific mirror. However I recently started using cpanm at the advice of a friend, and I can't seem to find a way to set the default mirror without specifying --mirror http://cpan.metacpan.org on the command line each time.

Is there an environment variable or a config file that I can set the default mirror?

As for why I would want to simply not use the default list of mirrors, I am an FI and we are firewalled to no end. Only one mirror has been allowed through our firewall.


Solution

  • Cite from the cpanm docs

    ENVIRONMENT VARIABLES

    PERL_CPANM_OPT If set, adds a set of default options to every cpanm command. These options come first, and so are overridden by command-line options.

    So try: export PERL_CPANM_OPT="--mirror http://cpan.metacpan.org"