11

I can't find the answer to this anywhere: Does a module installed via APT conflict with one installed via CPAN?

Along with that question are these: Where do the installed CPAN modules live? Are they accessible globally or just to the installing user? How do you know which one? How do you know what's installed and which takes precedence?

Should CPAN even be used when modules are installed via APT?

4 Answers 4

10

On Debian and 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/. So files installed via /usr/bin/cpan won't overwrite files installed via apt.

There's nothing wrong with using system perl, and mixing apt and cpan code will generally work.

You can also choose to package any cpan distribution not available in your apt repositories manually. It's easy with the help of dh-make-perl tool:

dh-make-perl --cpan Some::Module && cd Some-Module* && sudo debi
2
  • The location where cpan installed modules end up is determined by PERL's Config.pm. On my Ubuntu 11.04, it is /usr/local/share/perl/5.10.1. Commented Aug 21, 2011 at 12:51
  • I think it's /usr/local/share for pure-perl modules and /usr/local/lib for xs stuff.
    – berekuk
    Commented Aug 21, 2011 at 12:58
6

I use perlbrew. It installs a local version of Perl and cpan. Everything it does is done in your home directory. It's straight forward to install and use and you can install the latest version of Perl.

1
  • 2
    That's also good if you want to depart from the system perl.
    – szabgab
    Commented Aug 21, 2011 at 7:22
4

When installing from CPAN directly I would recommend using local::lib to a directory private to you. See the boostrapping technique https://metacpan.org/module/local::lib

That way the CPAN installed module will be only used by your user and it will have a very clean separation from the modules installed using APT.

It will also make it easy to get rid of the CPAN-installed modules if you encounter any issue or when you upgrade Ubuntu.

That's how I use it on Ubuntu.

1

You can use both but they will conflict. They're written to the same place so if you install something from apt and then install a later version from cpan, you could bodge things up.

I don't do much Perl but in Python I certainly have the dilemma you're talking about: apt-vs-PyPI. I personally opt for apt whenever I can. It means I should get updates without having to remember to maintain each individual Python package. Not only that but it means that all my systems should be running on the same version of those packages.

It doesn't always work out. Sometimes you don't have new enough things in the repos or something you need just isn't packaged up. Neither way is perfect but I believe apt to be more perfect. Just be aware of what you're doing and you should be okay.


Edit - Almost forgot, there is a better way to section things up so the system can have its own environment and whatever you're developing can live in its own environment (that you manage completely with CPAN), Like Python's virtualenv...

https://stackoverflow.com/questions/1423879/how-can-i-install-specialized-environments-for-different-perl-applications

3
  • I was hoping that CPAN would install to some Site or site directory - or that at least you could force it.
    – Mei
    Commented Aug 15, 2011 at 1:54
  • 3
    Note: on Ubuntu, cpan-installed modules end up in /usr/local/share/perl (or the location specified by PERL's Config.pm), whereas APT packages end up in /usr/share/perl5 as per Debian policy. So they do not conflict, and it is safe to mix and match CPAN and APT installations, as the other answers say. (Python is not a good analogy here: PERL packaging and module handling is much different and -IMHO- superior to Python's.) Commented Aug 21, 2011 at 12:49
  • @Riccardo: quite right. The same holds for Red Hat as well, though to a different location.
    – Mei
    Commented Aug 22, 2011 at 2:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .