Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Proper CPAN Installation

by Cmdr Colstel (Novice)
on Sep 22, 2015 at 03:11 UTC ( [id://1142694]=perlquestion: print w/replies, xml ) Need Help??

Cmdr Colstel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Perl Monks,

I know this question has been asked before, but I can't seem to get consistent answers. I'm hoping your experience can guide me in the right direction. I attempted to install CPAN and I believe I have two installs, one in the ~/.cpan directory and the other in /var/root/.cpan directory. Is this normal or should I get rid of one ? If not proper, which one should I remove ?

I think I did one with sudo su and one without.

Thanks Again

Replies are listed 'Best First'.
Re: Proper CPAN Installation
by trippledubs (Deacon) on Sep 22, 2015 at 03:46 UTC

    I would get rid of both and use http://perlbrew.pl. Perlbrew is a program that manages your whole perl environment. Most Unix variants rely on the Operating System installed Perl for whatever, so it is not safe to screw with.

    Perlbrew lets you keep different version of Perl with different local cpan installations. It is really nice to have and solves your current dilemma, which is mostly a subjective decision. It is not going to hurt to have two .cpans, just annoying. Installing software of unknown origin as root, also annoying, and potentially subvertible. Installing as an unprivileged user, can only compromise ports 1025-65535, and everything that user has access to.

    Updated: link
      Perlbrew lets you keep different version of Perl with different local cpan installations

      I don't use perlbrew, but I expected it would be possible to configure it such that *all* perls it builds use the same .cpan location.
      My perls all use the same .cpan directory. It would really annoy me if I had to repeatedly download the same source tarball - one for each perl that I have.

      Cheers,
      Rob
        According to the perlbrew site, there is an option available for installing a cpanm instance that is shared across the different perlbrew perls.
        perlbrew install-cpanm
        I think it will store it's configuration and data files (such as sources) in ~/.cpanm. I do not see similar support for cpan. I have not used this feature of perlbrew, so if I'm not correct, I hope someone will correct me.

        "I don't use perlbrew, but I expected it would be possible to configure it such that *all* perls it builds use the same .cpan location."

        Nope! But this should not be a problem ... why? Because why are you installing multiple Perls? I install them so i can test the installation of my CPAN releases and as such, NOT having the same modules shared across multiple perls actually is a benefit to me, because i see what a completely fresh install of my module entails. (Did i really get that dependency correct?)

        As far as provisioning your installed perls via perlbrew ... just keep a record of the CPAN modules you use and install them all with one fell swoop: cpanm -n Dancer WWW::Mechanize YAML JSON etc. (and yes, i recommend skipping CPAN module tests because many authors do not care how long their tests take to complete.) This is where your Puppet/Chef/cfEngine3 manifest comes into play ... you do have one, don't you? :)

        jeffa

        L-LL-L--L-LL-L--L-LL-L--
        -R--R-RR-R--R-RR-R--R-RR
        B--B--B--B--B--B--B--B--
        H---H---H---H---H---H---
        (the triplet paradiddle with high-hat)
        
Re: Proper CPAN Installation
by kevbot (Vicar) on Sep 22, 2015 at 04:28 UTC
    Hi Cmdr Colstel,

    I agree with trippledubs that perlbrew is the way to go. When you use perlbrew, you can install modules as a normal user. It will allow you to avoid using sudo, and avoid perturbing the system perl.

    If you install a perl with perlbrew, you may want to consider using cpanminus as an alternative to the cpan application. Cpanminus works very well with perlbrew. See the Installing to local perl (perlbrew, plenv etc.) section of the cpanminus documentation.

Re: Proper CPAN Installation
by Anonymous Monk on Sep 22, 2015 at 06:55 UTC

    I know this question has been asked before, but I can't seem to get consistent answers. I'm hoping your experience can guide me in the right direction. I attempted to install CPAN and I believe I have two installs, one in the ~/.cpan directory and the other in /var/root/.cpan directory. Is this normal or should I get rid of one ? If not proper, which one should I remove ?

    I think I did one with sudo su and one without.

    What question?

    CPAN comes installed with perl, so you shouldn't need to install it, but you might need to configure it, so

    So which configuration did you create and which one already existed?

    How did you configure the one you created?

    Leave everything alone :)

    Spend some time reading the following and come back and ask questions

    https://metacpan.org/pod/CPAN#CONFIGURATION and sh Configure -Dprefix=/home/username/perl -des and PERL5LIB/A Guide To Installing Modules/perlmodinstall/Re: Unable to install perl module Sendmail...

    Also heed the advice of the others, leave the system/vendor perl alone , install your own, you don't need perlbrew to install your own its just a helper

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1142694]
Approved by kevbot
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found