My company’s policy for Perl in production is more or less:
- Production Perl code must run under the vendor supplied Perl
- Sysadmins will not install or upgrade Perl modules
- We are allowed to install any module from CPAN
The two production platforms we target are RHEL5.5 for which vendor Perl is an uncomfortable 5.8.8 and RHEL6.2 which has a much more comfortable Perl 5.10.1.
Our development boxes do not have access to the internet proxies which makes things a little more difficult than they should be.
David Golden lists 5 ways of installing module prerequisites here.
Installing Perl Modules – Method #6
The method I use, given the constraints above is to discover the prerequisites by running Makefile.PL
(or Build.PL) and download the prerequisites by hand recursively.
This approach is straightforward once you have the correct Makefile.PL incantation.
PERL_LIB="$HOME/lib/perl5"
perl -I$PERL_LIB Makefile.PL PREFIX=$PERL_LIB LIB=$PERL_LIB PERL="/usr/bin/perl -I$PERL_LIB"
Note: You could set/override environment variable PERL5LIB
instead of adding the -I arguments which is probably better, but aesthetically, I prefer the version above.
How much trouble will you be in when they discover that you are breaking their rule about not installing CPAN modules?
It’s clearly ridiculous to use Perl without using CPAN modules. Have you attempted to get these rules changed? Or, if that proves impossible, have you considered looking for another job? š
cpanm’s -l option will basically do that for you, without needing you to resolve dependencies manually. And if you would prefer to use cpan instead of cpanm, look up local::lib.
@realdavorg – the firm does permit CPAN modules to be installed. It would be tough to be somewhere that it wasn’t allowed, I agree.
@Graham – how does cpanm work, when the server with Perl installed can’t access the internet?
You might look at Carton. Build a Carton bundle on a system with internet, then install it on the isolated box.
We have a similar setup. My solution was to create an internal cpan repository and added a “distinstall” command and option to Module::Builder. The local cpan repos is populated from the .cpan/authors directory. The production server then points to this cpan repository and all local and cpan modules are installed from this repos on development w/ cpan install.
@joel – interesting suggestion… I had a quick glance at it, but I’m not sure it fits my use case. The PCs with internet are Windows PCs but development / deployment servers are Linux.
@rick – yep, I also considered a local cpan repository, but the manual effort isn’t too great. I’ve got about 27MB of modules installed in my local area and it took less than half a day to download / install / resolve dependencies / rince and repeat.
No, this is wrong in so many subtle way I don’t know where to start.
First of all, using both LIB and PREFIX is a bit double (LIB overrides PREFIX wrt modules, though I imagine it does matter for docs and scripts). Secondly PREFIX is batshit insane, if you think you know how it works you’re wrong. Thirdly, this is likely to break on XS modules, given you’re not including the archlib. Lastly, why are you doing this by hand? There are so many methods that are less work.