CPAN: Automatically install dependencies without confirmation

I enjoy using CPAN because it installs Perl modules with a simple interface, fetches dependencies, and warns you when things are about to end badly. However, one of my biggest complaints is when it constantly confirms installing dependencies. While this is an annoyance if you have to install a module with many dependencies (or if you're working with CPAN on a new server), you can tell CPAN to automatically confirm the installation of dependencies.

To do this, simply bring up a CPAN shell:

perl -MCPAN -e shell

Run these two commands in the CPAN shell:

o conf prerequisites_policy follow
o conf commit

Now, exit the CPAN shell, start the CPAN shell, and try to install a module that you need. All dependencies will be automatically confirmed, downloaded and installed.

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.

A big thanks goes out to Lee Hambley for the fix.

WARNING: There are some occasions where you would not want to install dependencies from CPAN. Examples of these situations are when your operating system's package manager (yum, up2date, apt-get, aptitude, etc) has installed Perl modules in an alternative location or when you have manually installed modules in a non-standard way. I'm a Red Hat guy, and these problems rarely arise on Red Hat/Fedora systems, but your mileage may vary.

Printed from: http://rackerhacker.com/2009/01/01/cpan-automatically-install-dependencies-without-confirmation/ .
© Major Hayden 2012.

7 Comments   »

  • Sam says:

    Note that CPAN will ask you to connect to the internet before you install any module. After that, it'll do what it's supposed to. So don't walk away or detach screen too quickly. :-)

  • delfry says:

    helo...
    do you know installing perl Module from cd/dvd without using CPAN , because i have not internet connection??
    thank you...

  • Luke Palmer says:

    Get flattr you bastard. I was looking for the flattr button on this post, because it was exactly what I needed. Thanks, but... I want to pay you! :-)

  • Admin says:

    Thank you! This will save me a ton of time!

  • Ron Betts says:

    awesome. just saved me a ton of time. I'm with Luke, I definitely think this man deserves a beer, a pizza, (some cash)? thank you sir.

  • Aaron Wilson says:

    connect_to_internet_ok option set to yes will make it connect to the Internet automatically.

  • Ashwini says:

    Hi,

    I have been facing issues with the last part of the installation:

    First, pick a nearby continent and country by typing in the number(s)
    in front of the item(s) you want to select. You can pick several of
    each, separated by spaces. Then, you will be presented with a list of
    URLs of CPAN mirrors in the countries you selected, along with
    previously selected URLs. Select some of those URLs, or just keep the
    old list. Finally, you will be prompted for any extra URLs -- file:,
    ftp:, or http: -- that host a CPAN mirror.

    (1) Africa
    (2) Asia
    (3) Central America
    (4) Europe
    (5) North America
    (6) Oceania
    (7) South America
    Select your continent (or several nearby continents) []
    Sorry! since you don't have any existing picks, you must make a
    geographic selection.

Trackbacks/Pingbacks

  1. Using CPAN Unattended | Mindless Techie

RSS feed for comments on this post

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden

    Flattr this