Mik Mik - 2 months ago 11x
Perl Question

How do I set up my Dockerfile to use cpanm to install a specific version of a Perl module?

Within my Dockerfile, I am setting up the Perl modules that will be installed when run, like so:

RUN ["cpanm", "Carp", "Carp::Heavy", "Class::Data::Inheritable"]

However, for one module, I need a specific version of a module, not the latest one. How can I specify that version in the above line?

I've been searching online for hours, and haven't turned up anything useful yet.


Instead of specifying a module name, specify a URL. Eg, instead of Class::Data::Inheritable, use https://cpan.metacpan.org/authors/id/T/TM/TMTM/Class-Data-Inheritable-0.06.tar.gz

You can find the applicable URL by going to the module page on metacpan, selecting the version you want, and copying the download link.

PS: You might want to also set PERL_CPANM_OPT=--from https://cpan.metacpan.org/ in the environment so cpanm only downloads using HTTPS.