ETOOBUSY 🚀 minimal blogging for the impatient
When I need to install Perl modules, I usually do this from CPAN directly without relying on the modules shipped with Debian. This allows me fine control over versions, etc., at the cost of not installing those modules in any place known to system perl.
(Sometimes I also find it useful to install my own
perl too, but this is
for another time).
To install modules locally for a project there are two very easy ways, i.e. Carton and Cpanminus. You don’t have to (explicitly) use both, and if you can go with Carton alone it’s probably the fastest way.
cpanfile, where your needs are explicit
Both tools (can) rely on a cpanfile, i.e.
A format for describing CPAN dependencies for Perl applications
This can be as easy as just list your needs in a clear way, like this:
requires 'Log::Log4perl::Tiny'; requires 'Try::Catch', '1.1.0';
carton, quick and to the point
If you can, just stick with Carton and you’re a word away from having your modules installed:
shell$ carton Installing modules using /home/poletti/tmp/cpanfile Successfully installed ExtUtils-Config-0.008 Successfully installed ExtUtils-InstallPaths-0.012 Successfully installed ExtUtils-Helpers-0.026 Successfully installed Module-Build-Tiny-0.039 Successfully installed Log-Log4perl-Tiny-1.4.0 Successfully installed Try-Catch-v1.1.0 6 distributions installed Complete! Modules were installed into /home/poletti/tmp/local
This will also produce a file
cpanfile.snapshot that you might want to put
under version control.
cpanm, elegant and fast
shell$ cpanm -l local --notest --installdeps . --> Working on . Configuring /home/poletti/tmp ... OK ==> Found dependencies: Try::Catch, Log::Log4perl::Tiny --> Working on Try::Catch Fetching http://www.cpan.org/authors/id/M/MA/MAMOD/Try-Catch-1.1.0.tar.gz ... OK ... Successfully installed Log-Log4perl-Tiny-1.4.0 <== Installed dependencies for .. Finishing. 6 distributions installed
cd ~/bin curl -L https://cpanmin.us/ -o cpanm chmod +x cpanm
You can also find an old standalone cpanm here.
This is all I wanted to scribble about installing Perl modules… it should not take unnecessary time for us to do it, nor to realize how to do it!