How do I tell CPAN to install all dependencies?

How do I tell CPAN to install all dependencies?

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

Is there a way to get it to always go ahead and install? I want to make it unattended.

It would seem that I want a flag to always trust CPAN to do the right thing, and if it suggests an answer I would like to follow it (always hit Enter when it asks something).


Solution 1:

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.

Solution 2:

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