Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 does 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?

share|improve this question
add comment

4 Answers 4

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
share|improve this answer
    
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. –  Riccardo Murri Aug 21 '11 at 12:51
    
I think it's /usr/local/share for pure-perl modules and /usr/local/lib for xs stuff. –  berekuk Aug 21 '11 at 12:58
add comment

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.

share|improve this answer
    
That's also good if you want to depart from the system perl. –  szabgab Aug 21 '11 at 7:22
add comment

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.

share|improve this answer
add comment

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...

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

share|improve this answer
    
I was hoping that CPAN would install to some Site or site directory - or that at least you could force it. –  Mei Aug 15 '11 at 1:54
2  
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.) –  Riccardo Murri Aug 21 '11 at 12:49
    
@Riccardo: quite right. The same holds for Red Hat as well, though to a different location. –  Mei Aug 22 '11 at 2:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.