See the bootstrapping technique for how to get started. You can create a directory per user/project/company and deploy to other servers, by copying the directory (as long as you are on the same operating system and perl version). cpanm from App::cpanminus is a script to get, unpack, build and install modules from CPAN.
Try setting PERL_MM_USE_DEFAULT like so:
PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install My::Module'
It should make CPAN answer the default to all prompts.
The latest and greatest answer to this question is to use cpanm
instead (also referred to as App::cpanminus or cpanminus)!
DESCRIPTION
cpanminus is a script to get, unpack, build and install modules from CPAN and does nothing else.
It's dependency free (can bootstrap itself), requires zero configuration, and stands alone. When running, it requires only 10MB of RAM.
To bootstrap install it:
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
or if you are using perlbrew
simply
perlbrew install-cpanm
or from cpan itself:
cpan install App::cpanminus
From then on install modules by executing (as root if necessary)
cpanm Foo::Bar
Here is the one-liner making these changes permanent including automatic first-time CPAN configuration:
perl -MCPAN -e 'my $c = "CPAN::HandleConfig"; $c->load(doit => 1, autoconfig => 1); $c->edit(prerequisites_policy => "follow"); $c->edit(build_requires_install_policy => "yes"); $c->commit'
Or combine it with local::lib
module for non-privileged users:
perl -MCPAN -Mlocal::lib=~/perl5 -e 'my $c = "CPAN::HandleConfig"; $c->load(doit => 1, autoconfig => 1); $c->edit(prerequisites_policy => "follow"); $c->edit(build_requires_install_policy => "yes"); $c->commit'
Run it before using the CPAN shell or whatever.
Changing the following parameter on top of prerequisites_policy follows.
cpan> o conf prerequisites_policy 'follow'
cpan> o conf build_requires_install_policy yes
cpan> o conf commit
This will change it from "ask/yes" to "yes" and stop it asking you.
Here's what I'm pretty sure you're looking for:
cpan> o conf prerequisites_policy follow
cpan> o conf commit
Maybe it's related to ExtUtils::AutoInstall or Module::AutoInstall being used. Try setting the PERL_AUTOINSTALL environment variable. (Cf. the documentation of those modules.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With