Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Perl module with assume yes for given options non-interactively

Tags:

perl

cpan

Normally in linux Debian we do sth like this to install a package non-interactively e.g

sudo apt-get install -y Package_x_z

#[-y --assume-yes]

How we can do the same while installing a perl module e.g

sudo perl -MCPAN -e 'install DBI'
like image 644
sakhunzai Avatar asked Aug 27 '13 06:08

sakhunzai


1 Answers

That prompt is (typically) coming from ExtUtils::MakeMaker's prompt() function. Stick export PERL_MM_USE_DEFAULT=1 in your .bashrc (or equivalent for your preferred shell) to stop the prompts. The ExUtils::MakeMaker man page documents it thus:

PERL_MM_USE_DEFAULT

If set to a true value then MakeMaker's prompt function will always return the default without waiting for user input.

Note that this can come to bite you if you run cpan(1) on a box that's not yet had CPAN repositories configured. It will rattle on and get stuck in a prompt loop at a point where there is no default and you need to make a choice, but have no ability to do so. export PERL_MM_USE_DEFAULT=0 in the shell before running cpan(1) will of course temporarily re-enable input.

like image 71
pndc Avatar answered Nov 09 '22 01:11

pndc