Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Installing specific versions of CPAN modules

by Mutant (Priest)
on Aug 08, 2008 at 14:34 UTC ( #703131=perlquestion: print w/replies, xml ) Need Help??

Mutant has asked for the wisdom of the Perl Monks concerning the following question:


I'm not sure if this is possible, but I'm trying to create a way to build a set of CPAN modules of a specific version so that this build can be repeated (e.g. on another platform).

The approach I was hoping to take was:

  • Have a list of modules (preferably, but distributions would be OK) with version numbers in a text file
  • Have a script that reads the list of modules, and checks whether that specific module is already installed on this system
  • If it's not, it downloads the specific version of that module from CPAN (assuming it's available) and builds and installs it, including all depedencies
  • Ideally it should do nothing if the module is already installed

I was hoping would help me, but it seems geared towards installing only the latest version of a module. i.e. there's no way to specify a specific version to download/install. You can give it a specific distribution name, but older versions won't be in the index, so you can't find out which modules they contain, and therefore can't find out if they've already been installed on the system.

In case it's not immediately obvious, the reason I need to do this is so that I can maintain a set of CPAN modules across multiple platforms (i.e. different OSes / CPUs) which may be added to at a later date, requiring the set of modules to be re-built. For paranoid reasons, the modules need to be the same versions as exist on the other platforms.

Anyone have any ideas how to solve this?

  • Comment on Installing specific versions of CPAN modules

Replies are listed 'Best First'.
Re: Installing specific versions of CPAN modules
by Fletch (Bishop) on Aug 08, 2008 at 14:44 UTC

    The bundle mechanism (see the docs for autobundle and the section "Bundles" in the CPAN pod) allows you to create a specially formatted module which names modules and versions to install. If that's not precisely what you need maybe it can be massaged more towards what you're looking for.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: Installing specific versions of CPAN modules
by davorg (Chancellor) on Aug 08, 2008 at 15:05 UTC

    In a situation like this I think I'd manually download the required distributions from CPAN (or BACKPAN if necessary) and keep a local repository.

    Actually, I'd probably build a set or RPMs (or .debs if you're that way inclined) to make it easier to install them all.


    See the Copyright notice on my home node.

    "The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg

Re: Installing specific versions of CPAN modules
by JavaFan (Canon) on Aug 08, 2008 at 14:52 UTC
    If the reasons are paranoid, I wouldn't rely on downloading them from CPAN.

    Download the modules you need, and put them in your own repository. This could be a repository with a CPAN structure (which you can have your CPANs Config point to), or a repository using your local package system. A yum repository with RPMs for instance. Another advantage of having a local repository, using your local package system, is that you can prebuild (compile) your modules, making installation faster.

Re: Installing specific versions of CPAN modules
by MidLifeXis (Monsignor) on Aug 08, 2008 at 17:40 UTC

    If it's not, it downloads the specific version of that module from CPAN (assuming it's available) and builds and installs it, including all depedencies

    I would recursively install the version of the dependancy that you require by hand update, or you can still end up with inconsistent installations.

    I have a configuration file that lists the dependancies at the top, items that depend on them at the bottom, and a repository of the tar.gz files called out in that configuration file that I use for builds. I can do a full recompile and install of everything I need for my system starting from a bare known OS install with a single command.

    Building the configuration file the first time, now that is the pain.


Re: Installing specific versions of CPAN modules
by tptass (Sexton) on Aug 08, 2008 at 15:18 UTC

    I do not always have the luxury of being able to connect to CPAN, sometimes firewalls, sometimes no direct outside connection and have found the best way is to create a perl script that does all the installation steps for each module manually.

    You will have to build them individually each time across the different platforms or else you will have issues. And if you are truly a paranoid one, you should want to download the exact version and store it locally for installation. This will give you the ability to take care of any dependency issues you have and will allow you to install on any platform all you will have to do is run the script created that will do the run the following commands at minimum for each module:

    my @modules = qw ( moduleDir1 moduleDir2); foreach my $module (@modules){ chdir("$module"); system("Perl Makefile.PL"); system("make"); system("make install"); chdir("../"); }
      I would hope that you deal with errors on the 'make' and run tests too?


        That would be ideal, all I was hoping to portray was a code stub to could used to achieve what was trying to be done. Yes error checking and tests would be great.

        I am not and wasn't on a computer where I actually have access to my exact code that I used to install my modules, but I do both of them in there, and would recommend you do it to because it has saved me hours of debugging in the past.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://703131]
Approved by mr_mischief
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2023-03-24 00:43 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.