How do I tell CPAN to install all dependencies?

后端 未结 10 982
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 16:27

How do I tell CPAN to install all dependencies?

I tried setting these in cpan:

cpan> o conf prerequisites_policy follow
cpan> o co         


        
相关标签:
10条回答
  • 2020-11-30 16:55

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

    0 讨论(0)
  • 2020-11-30 16:57

    I'm writing this for benefit of people who may have come to this page searching for a way to install all module dependencies needed by a particular perl script. I wrote a script for that:

    It should be run as ./installdep.pl yourscript.pl

    #!/usr/bin/perl
    `sudo apt install cpanminus`;
    while (<>) {
        if (/USE /i)
        {
            my $line=$_;
            $line=~ s/\s//g;
            $line=~ /^(.*)\./;
            $line=~ s/\;//;
            $line=~s/^USE//i;
            $line=~s/lib.*//i;
            $line=~s/feature.*//i;
            $line=~s/strict//i;
            $line=~s/warnings//i;
            $line =~ s/^(.*)\(.*/$1/;
            unless ($line eq '') {
            my $cmd='sudo cpanm '.$line;
            print "Installing $line \n";
            open my $cmd_fh, "$cmd |";
            while (<$cmd_fh>) {
              print "$_";
            }
            close $cmd_fh;
            print "\n";
        }
        }
    }
    

    This will use cpanminus to install all module dependencies required by your script. If cpanm isnt installed, it will install it.

    0 讨论(0)
  • 2020-11-30 16:58

    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.

    0 讨论(0)
  • 2020-11-30 16:59

    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.

    0 讨论(0)
  • 2020-11-30 17:11

    I found this to be, by far, the quickest and most reliable way to install CPAN modules:

    yes | perl -MCPAN -e "CPAN::Shell->notest(qw!install Your::Module!)"
    
    0 讨论(0)
  • 2020-11-30 17:12

    Set

    prerequisites_policy
    

    in the configuration.

    See Config Variables.

    0 讨论(0)
提交回复
热议问题