Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automatically install missing modules from CPAN

If I want to distribute a Perl script, what is the best way to painlessly install any required modules that are missing on the user's system? Extra credit if there is a way to even install/upgrade Perl itself if it is missing or "too old".

like image 358
JoelFan Avatar asked Nov 18 '11 13:11

JoelFan


People also ask

Where do CPAN modules get installed?

CPAN doesn't actually install files. It runs the install script embedded in each distribution, which then performs the actual install. For distributions using ExtUtils::MakeMaker, the defaults are documented here: https://metacpan.org/pod/ExtUtils::MakeMaker#make-install (and the default value of INSTALLDIRS is site ).

How install perl modules Linux CPAN?

To install Perl modules using CPAN, you need to use the cpan command-line utility. You can either run cpan with arguments from the command-line interface, for example, to install a module (e.g Geo::IP) use the -i flag as shown.

How install CPAN Perl Module Ubuntu?

One possible solution is to install libcgi-pm-perl , which currently replaces the default version by a supported one (2011-0-10). To do so, type sudo apt-get install libcgi-pm-perl from the command line or install it with your favorite package manager. Gentoo has ebuilds for the CPAN.


4 Answers

Auto-installing software is the best way to make both end users and sysadmins very angry with you. Forget about this approach.

You can simply ship all your dependencies with your application distro, the inc directory is customary.

like image 122
daxim Avatar answered Oct 12 '22 20:10

daxim


Usually this ends with CPAN-like package creation. So, when you need to install all dependencies you type make installdeps

See perldoc perlmodlib Also Module::Install may be useful for you and some Makefile.PL example

Makefile.PL allows you to define deps and required perl version. Also you may add

use 5.010;

To your script in order to require minimal version of perl to run. See perldoc -f use for details.

like image 38
yko Avatar answered Oct 12 '22 18:10

yko


Why not use pp (PAR Packager) that creates an executable. No need for Perl or anything on the target machine.

like image 2
Bill Ruppert Avatar answered Oct 12 '22 19:10

Bill Ruppert


If you look at cpanminus, this you can install by simply executing one file:

curl -L http://cpanmin.us | perl - --self-upgrade

This might be the behaviour you're looking for; it's done with App::Fatpacker. Check it out:

https://metacpan.org/module/App::FatPacker

like image 2
MichielB Avatar answered Oct 12 '22 18:10

MichielB