75

There are multiple installers for cpan modules available; I know of at least CPAN.pm (comes with perl,) CPANPLUS, and cpanminus.

What is the difference between the three?

What situations call for using one over the other?

Are there other module installers I should know about?

hobbs
  • 223,387
  • 19
  • 210
  • 288
Sean McMillan
  • 10,058
  • 6
  • 55
  • 65

5 Answers5

84

CPAN.pm (cpan) is the original client. It comes with Perl, so you already have it. It has the most features. It has a lot of configuration options to customize the way it works, though virtually everyone accepts the default installation. It integrates easily with local::lib.


cpanminus (cpanm) is an attempt to make a zero-configuration client that automatically does the right thing for most users. It's also designed to run well on systems with limited resources (e.g. a VPS). It doesn't come with Perl, but it's easy to install. It integrates easily with local::lib.

Its biggest limitation is its lack of configuration. If you want to do something unusual, it may not support it.


CPANPLUS (cpanp) is an attempt to make a CPAN API that Perl programs can use, instead of an app that you use from the command line. The cpanp shell is more of a proof-of-concept, and I don't know of any real advantages to using it.


In summary, I'd recommend either cpan or cpanm. If you have trouble configuring cpan, try cpanm. If your situation is unusual, try cpan.

ikegami
  • 367,544
  • 15
  • 269
  • 518
cjm
  • 61,471
  • 9
  • 126
  • 175
  • 3
    The latest cpan(1) also integrates with local::lib :) – brian d foy May 03 '11 at 05:33
  • I can't speak of modern cpan(1) but, previously cpanp was significantly better at resolving circular dependencies. – Evan Carroll Apr 02 '13 at 19:00
  • yeah, cpan or cpanm. doesn't matter – dns May 04 '13 at 17:31
  • 2
    Maybe this could be amended to include [`cpm`](https://metacpan.org/release/App-cpm) as well. – simbabque May 21 '18 at 12:11
  • Re "*an attempt to make a zero-configuration client that automatically does the right thing for most users.*", You're seem to be implying `cpan` doesn't do this, but `cpan` and `cpanm` does the same thing by default. (`cpan` additionally gives you the option of changing things, but that's totally optional.) I really wish someone gave a reason for using `cpanm` other than it uses less memory. – ikegami Sep 07 '20 at 22:52
12

It's impossible answer this question because it is too subjective. :)

From my point of view: cpanm is the simplest way install perl modules. You can install cpanm with:

curl -L http://cpanmin.us | perl - --sudo App::cpanminus

and after it you can install modules with simple:

cpanm Some::Module

You can use cpanm for mirroring (part of) CPAN to you local machine too, so IMHO cpanm is the best for the most common CPAN needs.

chicks
  • 2,393
  • 3
  • 24
  • 40
clt60
  • 62,119
  • 17
  • 107
  • 194
  • That is a fabulous one liner! – Joshua Hoblitt Nov 03 '11 at 04:50
  • 1
    Uuuuh ... using sudo here is usually a bad idea. – reinierpost Mar 19 '13 at 16:12
  • 1
    @reinierpost - sure, as usually: _paranoia is the right mind-state of system administrators_ . :) But my second half believing to docs: http://search.cpan.org/dist/App-cpanminus/lib/App/cpanminus.pm#Installing_to_system_perl – clt60 Mar 20 '13 at 16:39
  • 1
    How is executing `curl -L http://cpanmin.us | perl - --sudo App::cpanminus` simpler than executing nothing at all? `cpan` is already installed if you have `perl`. – ikegami May 22 '18 at 04:32
  • @ikegami sure. For me the `cpanm` works much better as `cpan`. I'm an perl-idiot, I need things which "just works". The `cpan` isn't for me - needs too much learning ;) - but, probably for the perl-monks it is the "right" tool. – clt60 May 23 '18 at 11:46
  • @jm666, Re "*For me the cpanm works much better as cpan.*", How so? They both do exactly the smae thing (they execute `perl Makefile.PL` + `make` + `make test` + `make install` or the same chain for M::B). The only difference is that `cpanm` hides the output ( :( ). /// Re "*I need things which "just works".*", That's an argument for using `cpan`, not `cpanm`. To setup `cpan`, you simply need to press enter. You have to install `cpanm` (and install::lib?) first. – ikegami May 23 '18 at 18:08
  • @ikegami Many years ago I has zillion problems configuring `cpan`. It wasn't designed for the perl-novices. So tried the `cpanm` and it worked, and I never looked back. Based on your comment, now I tried the `cpan` again, and yes, it works. (even the auto-configuration as you said). But in the future I will continue to use the `cpanm` anyway, because (as you also said) it hides the unnecessary and irritating output. It is much more "unix-like", e.g. it is (nearly) silent when no problems here. Thank you for comments anyway - again learned something new today. :) – clt60 May 23 '18 at 21:32
  • @ikegami yes - i tried it and works - already said this. Something isn't clear? sry - my english isn't my main language... – clt60 May 23 '18 at 21:37
  • @jm666, don't put words in my mouth. I didn't say it hid *unnecessary* or *itritating* output. Quite the contrary. It hides important output. – ikegami May 23 '18 at 21:37
  • @ikegami ah understand - yes - youre right. of course. sry for the wording. :) – clt60 May 23 '18 at 21:39
8

Are there other module installers I should know about?

If you're using a Linux distribution that packages CPAN modules, then it's worth using their package installation program to install modules. For example, Ubuntu/Debian have a huge number of CPAN modules that you can install using 'apt' and Red Hat/Centos/Fedora have a number that you can install using 'yum'.

Dave Cross
  • 68,119
  • 3
  • 51
  • 97
  • 2
    It's worth noting that you often see projects advise against this approach because the packages are often quite out of date and it binds you to a single system-wide version, contained in a single system-wide set of all installed modules. For simple cases this is indeed probably the way to go but it's worth learning about local::lib/cpan (or pip/virtualenv, rbenv/rvm). – Sam Brightman Dec 22 '15 at 05:41
  • @SamBrightman You might want to answer or comment on the following question: http://serverfault.com/questions/805850/good-practice-regarding-multiple-package-management-systems – bli Nov 14 '16 at 13:56
4

CPAN is the standard. cpanminus (cpanm) asks fewer questions (best most of the time). I don't know anyone that uses cpanplus.

Since what these modules do is download, compile and install (place files in correct places) they all should do the same task. Some of the difference has to do with the permissions level you have. Perhaps you want to install some things local to your user and some things globally then you need a finer adjustment. Developers may also need to control/interrupt the process for debugging etc.

For daily use, use cpanm, unless you are too lazy to install it, then CPAN is fine.

Joel Berger
  • 20,180
  • 5
  • 49
  • 104
  • 1
    I didn't downvote, but please read on meta why comment-on-downvote was not made compulsory - they touch some pretty good arguments... no need to use hard words. – Konerak May 03 '11 at 19:22
  • 1
    @Konerak, when my answer has the same content (posted earlier, not so eloquent) as the accepted and well voted answer, I get irked when mine is not only ignored but rather downvoted – Joel Berger May 04 '11 at 01:19
  • I see what you mean and I too love getting my downvotes explained (at least that way I **can learn something**), but don't underestimate eloquence and formatting ;) – Konerak May 04 '11 at 06:20
0

cpanm uses much less memory. This makes it a better choice for environments where RAM is limited, such as shared hosting servers, where regular cpan might die before completing installation task, due to attempting to use more than available memory.

According to cpanm's (1.7044) documentation "When running, it requires only 10MB of RAM"