How do I tell cpan to install all dependencies?

Written by:

I’ve been racking my brain on how to get cpan to auto install all dependencies and not prompt me to respond to questions. After digging around several blogs, I found the following that solves my issue to a tee.

Edit:
After following Sinans link.
I tried setting these in cpan:

cpan> o conf prerequisites_policy follow
cpan> o conf commit

I still had to answer y a couple of times. (but fewer than before it feels like)

Any way to get it to always go ahead and install? I want to make it unattended.

Edit2:
It would seem that I want a flag to always trust cpan to do the right thing, if it suggests an answer I would like to follow it. (allway hit enter when it asks somthing)

brian d foy

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

From then on install modules by executing (as root if necessary)

cpanm Foo::Bar

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.

kbosak

Here’s what I’m pretty sure you’re looking for:

cpan> o conf prerequisites_policy follow
cpan> o conf commit

Mark C

changing the following parameter on top of prerequisites_policy follow

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.

Thomas

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.)

tsee

Set
prerequisites_policy
in the configuration.

See http://search.cpan.org/perldoc/CPAN#Config_Variables

Personally I have only tried a couple of times to modify the settings in that way and have actually found it easier to drop into the CPAN.pm shell by giving cpan no arguments, then configuring CPAN.pm from the interactive prompt:

$ cpan
cpan> o conf init

This will initiate the CPAN.pm interfaces configuration utility. Simply run through it and specify “follow” where you need to ( I forget the question offhand ) and you should be good to go.

Regards,

Jeff

brian d foy

If you want a scripted solution, look at the accepted one. For me though, I found that holding the return key after typing the command for 10 seconds will probably accept all defaults :P

kizzx2

I have not tried it, but can you use

yes | cpan [options]

in your scenario?

Anon Guy

How do I tell cpan to install all dependencies?
0 votes, 0.00 avg. rating (0% score)

Leave a Reply