purpose of installing a perl module with apt-get instead of cpan
Asked Answered
O

6

10

While loading necessities into my crouton, apt-get recommended that I install libtemplate-perl. This seemed a jolly idea, and I obeyed.

Reading this answer, I see a fellow traveler install Plack and Starman via CPAN, but then use apt-get to install Dancer.

Minutes before reading said answer, I had installed Dancer via CPAN. And it had worked. It had worked real good!

What happens differently when I install a CPAN package via a non-CPAN package manager? Are there pitfalls I need to be wary of because my libtemplate-perl came from apt-get, or my Dancer came from CPAN?

Oestradiol answered 14/7, 2014 at 0:45 Comment(0)
G
12

On Debian or Debian based distros like Ubuntu, CPAN (/usr/bin/cpan utility) installs modules into /usr/local/lib/ by default. And Debian packages keep their files in /usr/share/perl5/ and /usr/lib/perl5/.

It's a better way to choose dh-make-perl tool to package any CPAN distribution not available in your apt repositories, to avoid making mess (serious risk of conflict between apt and CPAN):

dh-make-perl --build --cpan Some::Module
dpkg -i some-module*.deb

Also check out about local::lib and perlbrew.

Gast answered 14/7, 2014 at 5:37 Comment(1)
A short, correct answer with bonus information -- the best!Oestradiol
P
7

A lot of tutorials, Stack Overflow answers, walk throughs, etc. will not want to assume that you know how to use /usr/bin/cpan and will instead suggest that you use your system's package manager, which you are more likely to be familiar with.

This is especially true if you are using a tool written in a particular language, but you don't know that language. For example many people wouldn't care whether crouton is written in Perl, Python or Lisp, they just want a tool they can use. Your average Debian or Ubuntu user is more likely to be familiar with apt-get than with cpan.

If you are looking to program in Perl I recommend installing things by cpan, using perlbrew and/or local::lib. If you are just looking to install a tool you can use, I would recommend using apt-get.


Additionally apt-get has the advantage that non-Perl dependencies will be installed automatically. For example the CPAN module XML::LibXML requires that the libxml2 headers are available on the system; the CPAN distribution has no way of stating that as a dependency, and will simply fail on install if it can find the headers to link against. The Debian package can actually specify that libxml2 is a dependency, and will install the dependency automatically for you.

Despite that if you are looking to use XML::LibXML as a Perl programmer, I would recommend installing it with cpan and installing the libxml2 package via apt-get. Having all your Perl modules installed in the same place - again, via perlbrew or local::lib - will help you keep your sanity in the future. CPAN is preferable to apt-get in this case because not all distributions have been packaged for Debian, and so you get a lot more options if you use CPAN directly.


In summary: TIMTOWTDI ;-)

Plath answered 14/7, 2014 at 6:50 Comment(0)
S
3

Another difference to mention that I don't see in other answers, is that if you use CPAN to install a module then the module version you get will be set, until you decide to upgrade that module. Whereas, if you use apt and a later version appears in Debian at some point in the future, then apt-get upgrade will update it.

Maybe you want that, maybe you don't. It's neither necessarily an advantage, nor a disadvantage. Simply a difference to be noted.

Synergistic answered 16/7, 2014 at 8:10 Comment(0)
T
1

The good things about apt-get are

  • that you can uninstall the packages afterwards should you need to

  • if you are maintaining any number of servers it is quicker to use apt-get as there is no building required

  • there are definite versions of packages which are tested for compatibility

The downsides are

  • not necessarily the latest version of packages

  • not all packages are available

Touter answered 14/7, 2014 at 7:15 Comment(0)
A
0

apt-get installs are generally easier and better than cpan because of dependencies alone.

If you are so lucky as to need SOAP::Lite, for example, it is many dozens of dependencies, and a one-line "apt-get install libsoap-lite-perl".

It is sometimes not clear how Perl CPAN names map to their repository package names, but "apt-cache search " is your friend.

Arcboutant answered 3/4, 2015 at 18:9 Comment(0)
R
0

Another approach, that can be used for any distro in HOME install as simple user:

Pros

  • avoid conflicts
  • up to date version of perl and modules
  • when you reinstall, you keep your home/perl as-si
  • you can upgrade all installed modules with $ cpan -r

Cons

  • you need to upgrade Perl manually

How to

Edit ~/.bashrc or such, and add:

export PERL5LIB=~/localperl/lib/
export PATH=~/localperl/bin:$PATH

Then

source ~/.bashrc

Install latest Perl5 from sources: https://www.cpan.org/src/README.html

Now, you have an isolate Perl installation in your home.

Enjoy the power to install any libs via:

$ cpan -i Whatever::Module
Ragg answered 6/7, 2020 at 1:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.