cpanminus - get, unpack, build and install modules from CPAN
cpan -h for more options.
cpanminus is a script to get, unpack, build and install modules from CPAN.
Its catch? Deps-free, zero-conf, standalone ~200 LOC script (i.e. hackable) and requires only 10MB RAM. See below for its cons.
Grab the file from http://bit.ly/cpanm, chmod +x, put it into your PATH. Adjust shebang if needed.
perl 5.8 or later (Actually I believe it works with pre 5.8 too but haven't tested).
LWP or 'wget' to get files over HTTP.
'tar' executable or Archive::Tar to unpack files.
C compiler, if you want to build XS modules.
make, if you want to more reliably install MakeMaker based modules
Module::Build (core in 5.10) if you want to install MakeMaker based modules without 'make'
No. Use CPAN or CPANPLUS.
OK, the first motivation was this: CPAN shell gets OOM (or swaps heavily and gets really slow) on Slicehost/linode's most affordable plan with only 256MB RAM. Should I pay more to install perl modules from CPAN? I don't think so.
Yes, I know there are tools like CPAN::SQLite that can fix that problem (and yes I use it on my Macbook Pro!) but installing it and its 14 non-core dependencies without CPAN shell (because CPAN shell doesn't work) feels like yak shaving.
So, imagine you don't have CPAN or CPANPLUS. What you're going to do
is to search the module on the CPAN search site, download a tarball,
unpack it and then run
perl Makefile.PL (or
perl Build.PL) and
make install (or
./Build install). If the module has
dependencies you probably have to recurively resolve those
dependencies by hand before doing so.
This script just automates that.
It scrapes the site http://search.cpan.org/. Yes, it's horrible and fragile.
Fetched files are unpacked in
~/.cpanm but you can configure with
CPANMINUS_HOME environment variable.
Yes, I think my brain has been damaged since I looked at PyPI, gemcutter, pip and rip.
It installs to wherever ExtUtils::MakeMaker and Module::Build are
configured to (i.e. via
MODULEBUILDRC). So if
you use local::lib then it installs to your local perl5
directory. Otherwise it installs to siteperl directory, so you might
need to run
cpanm command as root, or run with
--sudo option to
auto sudo when running the install command.
I tested installing MojoMojo, KiokuDB, Catalyst, Jifty and Plack using cpanminus and the installations including dependencies were mostly successful. So multiplies of half of CPAN behave really nicely and appear to work.
However, there are some distributions that will miserably fail, because of the nasty edge cases (funky archive formats, naughty tarball that extracts to the current directory, META.yml that is outdatd, META.yml that is not really YAML, circular dependencies etc.) while CPAN and CPANPLUS can handle them.
env PERL_MM_USE_DEFAULT=1 cpanm --notest Module
Oh, don't do that. It's too useful.
No, that's not my intention. This tiny script actually respects and plays nice with all the toolchain ecosystem that has been developed for years, such as: Module::Build, Module::Install, ExtUtils::MakeMaker and local::lib. It just provides an alternative to (but NOT a replacement for) CPAN or CPANPLUS, so that it doesn't require any configuration, any dependencies and has no bootstrap problems.
The thing is, I've learned that often for less experienced users, or even really experienced users who knows how to shoot in their feet, setting up a CPAN toolchain in the right way feels like just another yak to shave when all they want to do is just to quickstart writing perl code by installing CPAN modules. cpanminus is a super tiny shaver to eliminate the big yak really quickly in that case, and does nothing else.
No. Use CPAN or CPANPLUS.
Copyright 2010- Tatsuhiko Miyagawa
Parse::CPAN::Meta, included in this script, is Copyright 2006-2009 Adam Kennedy
Same as Perl.
Tatsuhiko Miyagawa, Goro Fuji, Kazuhiro Osawa, Tokuhiro Matsuno, Ken-ichi Ishigaki, Ian Wells
WE PROVIDE ABSOLUTELY NO WARRANTY OF ANY KIND EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THIS PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
IN NO EVENT SHALL THE UNIVERSITY OF TEXAS OR ANY OF ITS COMPONENT INSTITUTIONS INCLUDING M. D. ANDERSON HOSPITAL BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA OR ITS ANALYSIS BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES FROM) THE PROGRAM.