How can I install a specific version of a set of Perl modules?
Asked Answered
A

7

75

I'm tasked with replicating a production environment to create many test/sit environments.

One of the things I need to do is build up Perl, with all the modules which have been installed (including internal and external modules) over the years. I could just use CPAN.pm autobundle, but this will result in the test environment having much newer versions of the external modules that production has.

What is the easiest/best way to get and install (a lot of) version specific Perl modules.

Atalaya answered 4/11, 2008 at 2:3 Comment(0)
R
38

Make your own CPAN mirror with exactly what you want.

The CPAN tools only install the latest version of any distribution because PAUSE only indexes the latest version. However, you can create your own, private CPAN that has exactly the distributions that you want. Once you have your own CPAN mirror with only what you want, you point your CPAN tools at only that mirror so it only installs those versions. More on that in a minute.

Now, you want to have several versions of that. You can create as many mirrors as you like, and you can also put the mirrors in source control so you can check out any version of the mirror that you like.

Tools such as CPAN::Mini::Inject can help you set up your own CPAN. Check out my talks on Slideshare for the basic examples, and some of my videos on Vimeo for some of the demonstrations. Look at anything that has "CPAN" or "BackPAN" in the title. I think I might have some stuff about it in The Perl Review too, or should by the next issue. :)

Lately, I've been working on a program called dpan (for DarkPAN) that can look at random directories, find Perl distributions in them, and create the structure and index files that you need. You run dpan, you get a URL to point your CPAN client toward, and off you go. It's part of my MyCPAN-Indexer project, which is in Github. It's not quite ready for unsupervised public use because I mostly work with corporate clients to customize their setup. If you're interested in that, feel free to ask me questions though.

Also, I recently released CPAN::PackageDetails that can help you build the right index file. It's still a bit young too, but again, if you need something special, just ask.

Revegetate answered 4/11, 2008 at 3:41 Comment(1)
Thanks Brian, I'm currently in the process of building up a local mini cpan, I'll then inject in our local modules + those which I need downgraded to specific versions.Atalaya
D
110

bdfoy has the best large scale solution, but if you just want to install a few modules you can ask the CPAN shell to install a specific distribution by referencing a path to a tarball (relative to the top of the CPAN tree).

cpan> install MSCHWERN/Test-Simple-0.62.tar.gz

Throw a URL to BackPAN into your URL list and you can install any older version.

cpan> o conf urllist push http://backpan.perl.org/

This is in the CPAN.pm FAQ under "how do I install a 'DEVELOPER RELEASE' of a module?"

Darladarlan answered 6/11, 2008 at 6:27 Comment(5)
Nice. This let me work around a compatibility issue with a server I can't upgrade yet. Thanks!Spearhead
i don't think that URL works these days. this one does, though: backpan.perl.orgRacy
install MSCHWERN/Test-Simple-0.62.tar.gz @Darladarlan I think you need to lop off the M/MS prefix to get it to find the tarballJunitajunius
@TomH Either style appears to work, but you're right that yours is the documented one and it's simpler. Note that neither one will work for Test-Simple-0.62.tar.gz unless you're using a BackPAN URL.Darladarlan
@Chloe Fixed itDarladarlan
U
46
cpan install App::cpanminus
cpanm Your::[email protected]

(Carton, as referenced in other answers, uses cpanm underneath to resolve explicit version requirements.)

Unglue answered 30/5, 2015 at 0:32 Comment(3)
This is a great answer for specifically how to "install a specific version of a Perl module" (as the question appeared at one point). Especially if you're already using cpanm.Tort
Perfect: on debian-> aptitude install cpanminusYarmouth
To fix error Can't configure the distribution you need to run sudo apt-get install build-essential. Thanks for answer!Ahmedahmedabad
R
38

Make your own CPAN mirror with exactly what you want.

The CPAN tools only install the latest version of any distribution because PAUSE only indexes the latest version. However, you can create your own, private CPAN that has exactly the distributions that you want. Once you have your own CPAN mirror with only what you want, you point your CPAN tools at only that mirror so it only installs those versions. More on that in a minute.

Now, you want to have several versions of that. You can create as many mirrors as you like, and you can also put the mirrors in source control so you can check out any version of the mirror that you like.

Tools such as CPAN::Mini::Inject can help you set up your own CPAN. Check out my talks on Slideshare for the basic examples, and some of my videos on Vimeo for some of the demonstrations. Look at anything that has "CPAN" or "BackPAN" in the title. I think I might have some stuff about it in The Perl Review too, or should by the next issue. :)

Lately, I've been working on a program called dpan (for DarkPAN) that can look at random directories, find Perl distributions in them, and create the structure and index files that you need. You run dpan, you get a URL to point your CPAN client toward, and off you go. It's part of my MyCPAN-Indexer project, which is in Github. It's not quite ready for unsupervised public use because I mostly work with corporate clients to customize their setup. If you're interested in that, feel free to ask me questions though.

Also, I recently released CPAN::PackageDetails that can help you build the right index file. It's still a bit young too, but again, if you need something special, just ask.

Revegetate answered 4/11, 2008 at 3:41 Comment(1)
Thanks Brian, I'm currently in the process of building up a local mini cpan, I'll then inject in our local modules + those which I need downgraded to specific versions.Atalaya
T
10

[It's almost five years on and this is a well-asked and well-answered question that has had a lot of views. Since this page must still come up in Google searches, an update can't hurt.]

Carton is worth mentioning here. Carton is a relatively recent tool in the same style as App::cpanminus, App::cpanoutdated, perlbrew, et. al. The author (Miyagawa) calls it "alpha" quality, but even in its current state carton helps simplify the maintenance of multiple environments of version tuned modules across machines.

Pinto too is another recent tool relevant to some of the responses (in fact one of the respondents is a contributor).

Tutor answered 14/6, 2013 at 5:44 Comment(0)
H
4

Stratopan.com is another alternative. Stratopan provides private CPANs in the cloud. You can fill your Stratopan repository with specific versions of modules (and their dependencies) and then install them using the standard Perl tool chain. The repository changes only when you decide to change it, so you'll get always get the versions of the modules that you want.

Disclaimer: I operate Stratopan.

Hochman answered 5/12, 2013 at 21:1 Comment(0)
T
2

It seems that creating a cpanfile listing all your modules and desired versions (using the == <version> syntax to lock it to a specific release) could serve well here, too. That would mean using Carton or cpanm for installing the modules.

Doing this would have the benefit of being able to quickly/easily tweak the file to test upgrading specific modules in a dev or staging environment - something that a private CPAN mirror wouldn't let you do (without creating multiple mirrors).

Tort answered 22/3, 2016 at 15:18 Comment(0)
E
0

You can try this method if you have different version on a specific path.

sudo /usr/bin/perl -MCPAN -e 'install Net::OpenSSH'
Enrico answered 10/6, 2024 at 13:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.