Installing perl dependency automatically in perl

2019-01-15 14:58发布

问题:

I'm very new to perl. I wish I could install some package from perl, I did so like this :

perl -MCPAN -e 'install VM::EC2'

Its getting failed due to dependency I guess, it shows :

Result: FAIL
Failed 8/8 test programs. 9/9 subtests failed.
  LDS/VM-EC2-1.20.tar.gz
one dependency not OK (XML::Simple); additionally test harness failed
  ./Build test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports LDS/VM-EC2-1.20.tar.gz
Running Build install
  make test had returned bad status, won't install without force

In this case how do I ask perl to install XML::Simple and other depedency automatically?

Thanks in advance.

回答1:

Method 1: Using cpanm

You can either use cpanm and then use cpanm modulename command.

cpanm VM::EC2

The above command will install VM::EC2 module with all its dependencies automatically.

Method 2: Changing configuration of CPAN

or you can tell CPAN directly

$ perl -MCPAN -e shell
cpan[1]>  o conf prerequisites_policy follow
cpan[2]>  o conf commit
exit

The first line sets your dependency policy to follow rather than ask (the default). The second line tells CPAN to write the changes to your user's CPAN configuration file to make them permanent.

So the next time you try to install Perl module from CPAN shell, it will install all its dependencies without prompting you.



回答2:

You could use cpanm:

perl -MCPAN -e 'App::cpanminus'

and then

cpanm VM::EC2

look at the documentation for other features.