Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

perlbrew and cpan

by lcarter (Initiate)
on Aug 07, 2014 at 04:13 UTC ( [id://1096545]=perlquestion: print w/replies, xml ) Need Help??

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

Please clarify this for me.

  • Can I use cpan inside a perlbrew context -- to install perl modules to a particular perlbrew perl install, only.
  • Do I prefix the cpan install command with sudo? As in sudo perl -MCPAN -e'install Blah::blah'?
  • Can I actually use cpan to install modules in a particular perlbrew perl install only? Is that syntax without the sudo?
  • Thx

    Replies are listed 'Best First'.
    Re: perlbrew and cpan
    by CountZero (Bishop) on Aug 07, 2014 at 06:33 UTC
      Yes, you can use CPAN inside a perlbrew context.

      You can run CPAN under sudo but that is probably a bad idea. I think you will mess up your system's Perl that way.

      Runing CPAN (which is actually just another Perl script) without sudo will keep your install within the Perl instance you are running under at that moment. That's actually the whole idea of using perlbrew.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

        Thx.

        So it looks like I may have messed up my cpan and my system perl. And there is no good way to fix it except to restore from backup?

        lc

          You can fix the file ownership as follows:

          sudo chown -R $USER "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"

          The following fixes the group too, assuming the group name should be the same as your user name:

          sudo chown -R $USER:$USER "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"

          You didn't say how you messed up your system perl, so I can't offer any advice on how to fix it.

          So it looks like I may have messed up my cpan and my system perl. And there is no good way to fix it except to restore from backup?

          Why does it look that way to you?

    Re: perlbrew and cpan
    by DrHyde (Prior) on Aug 07, 2014 at 09:52 UTC

      I'll answer your first two questions with a couple of questions: what happens when you try it? and re sudo what happens when you try without it?

      As for your third, it depends on whether you want to install into the currently selected perl or some random perl. You can do both, but the second is slightly more complicated.

    Re: perlbrew and cpan
    by ikegami (Patriarch) on Aug 07, 2014 at 14:23 UTC

      Can I use cpan inside a perlbrew context -- to install perl modules to a particular perlbrew perl install, only.

      Yes.

      perlbrew use NAME cpan MODULE
      or
      "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}/perls/NAME/bin/cpan" MODULE

      (Replace NAME with the name of the perlbrew installation you want to use, and MODULE with the name of the module you want to install.)

      Do I prefix the cpan install command with sudo? As in sudo perl -MCPAN -e'install Blah::blah'?

      Not likely. The default settings for perlbrew places the Perl installations in your own home directory. It's unlikely that someone else installed a Perl there, so it wouldn't make sense to pretend to be someone else.

      Can I actually use cpan to install modules in a particular perlbrew perl install only? Is that syntax without the sudo?

      Seems you asked the same question twice?

    Re: perlbrew and cpan
    by Anonymous Monk on Aug 07, 2014 at 06:40 UTC

      Can I use cpan inside a perlbrew context -- to install perl modules to a particular perlbrew perl install, only.

      Yes, at least theoretically -- I've seen a few questions about perlbrew from folks who don't know to `which programname` to debug issues they encounter

      Do I prefix the cpan install command with sudo? As in sudo perl -MCPAN -e'install Blah::blah'?

      Are you root/sysadmin? sudo is for when a sysadmin is installing programs/perls/perl modules for everybody ... for day-to-day activities sysadmins don't login under the sysadmin account (root), so they sudo to do sysadmin tasks ...

      perlbrew is all about you installing perls/modules in your home directory for yourself

      sure its possible to shared perlbrew running as root, but then you wouldn't be asking these questions if this was the case :)

      Can I actually use cpan to install modules in a particular perlbrew perl install only? Is that syntax without the sudo?

      Yes, use perlbrew to switch current perl, then run cpan as normal (cpan Module::Name) and you'll install modules in the current perl

      I'm on win32 so I don't perlbrew, but I'd look for a perlintro equivalent for perlbrew :)

        perlintro for perlbrew is App::perlbrew - Manage perl installations in your $HOME

        shorter intro

        Install it in $HOME
            curl -kL http://install.perlbrew.pl | bash

        Install important friend
            perlbrew install-cpanm

        Install the perls you want, like the latest of each minor stable version
            perlbrew install-multiple perl-5.8.9 perl-5.10.1 perl-5.12.5 perl-5.14.4 perl-5.16.3 perl-5.18.2 perl-5.20.0

        Install modules you want into all perlbrew perls in one command (aka run one command for all perlbrew perls)
            perlbrew exec cpanm Path::Tiny Mojolicious Task::Kensho

        Switch to perl-5.16.3 and make perl-5.16.3 your default perl (perl ... runs perl-5.16.3 )
            perlbrew switch perl-5.16.3

        Synchronize all installed perls modules (aka run one command for all perlbrew perls)
            perlbrew list-modules | perlbrew exec cpanm

        Thx for your reply?

        The reason I am getting confused about sudo and the cpan command is because

      • I have never worked with non-system perl such as what perlbrew makes possible
      • It's not obvious to me that there is a cpan for each perlbrew install.
      • I cannot figure out how and where cpan will install the modules in an environment when there are multiple perls installed.
      • I actually have been googling all over the place in search for the answer. Seems like that added to my confusion.

        Thx

          I have never worked with non-system perl such as what perlbrew makes possible

          There's no difference between a distro-installed Perl and a perlbrew-installed Perl except in which directory they are installed.

          In fact, you can manage the system Perl with perlbrew simply by creating a symlink.

          cd "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}" mkdir perls/system ln -s /usr/bin perls/system/bin

          It's not obvious to me that there is a cpan for each perlbrew install.

          Each perlbrew has its own modules and binaries.

          I cannot figure out how and where cpan will install the modules in an environment when there are multiple perls installed.

          cpan asks the perl executing it for that information.

          $ "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"/perls/5.20.0t/bin/perl -V:' +inst.*' installarchlib='/home/ikegami/usr/perlbrew/perls/5.20.0t/lib/5.20.0/x8 +6_64-linux-thread-multi'; installbin='/home/ikegami/usr/perlbrew/perls/5.20.0t/bin'; installhtml1dir=''; installhtml3dir=''; installman1dir='/home/ikegami/usr/perlbrew/perls/5.20.0t/man/man1'; installman3dir='/home/ikegami/usr/perlbrew/perls/5.20.0t/man/man3'; installprefix='/home/ikegami/usr/perlbrew/perls/5.20.0t'; installprefixexp='/home/ikegami/usr/perlbrew/perls/5.20.0t'; installprivlib='/home/ikegami/usr/perlbrew/perls/5.20.0t/lib/5.20.0'; installscript='/home/ikegami/usr/perlbrew/perls/5.20.0t/bin'; installsitearch='/home/ikegami/usr/perlbrew/perls/5.20.0t/lib/site_per +l/5.20.0/x86_64-linux-thread-multi'; installsitebin='/home/ikegami/usr/perlbrew/perls/5.20.0t/bin'; installsitehtml1dir=''; installsitehtml3dir=''; installsitelib='/home/ikegami/usr/perlbrew/perls/5.20.0t/lib/site_perl +/5.20.0'; installsiteman1dir='/home/ikegami/usr/perlbrew/perls/5.20.0t/man/man1' +; installsiteman3dir='/home/ikegami/usr/perlbrew/perls/5.20.0t/man/man3' +; installsitescript='/home/ikegami/usr/perlbrew/perls/5.20.0t/bin'; installstyle='lib'; installusrbinperl='undef'; installvendorarch=''; installvendorbin=''; installvendorhtml1dir=''; installvendorhtml3dir=''; installvendorlib=''; installvendorman1dir=''; installvendorman3dir=''; installvendorscript=''; $ "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"/perls/5.18.2t/bin/perl -V:' +inst.*' installarchlib='/home/ikegami/usr/perlbrew/perls/5.18.2t/lib/5.18.2/x8 +6_64-linux-thread-multi'; installbin='/home/ikegami/usr/perlbrew/perls/5.18.2t/bin'; installhtml1dir=''; installhtml3dir=''; installman1dir='/home/ikegami/usr/perlbrew/perls/5.18.2t/man/man1'; installman3dir='/home/ikegami/usr/perlbrew/perls/5.18.2t/man/man3'; installprefix='/home/ikegami/usr/perlbrew/perls/5.18.2t'; installprefixexp='/home/ikegami/usr/perlbrew/perls/5.18.2t'; installprivlib='/home/ikegami/usr/perlbrew/perls/5.18.2t/lib/5.18.2'; installscript='/home/ikegami/usr/perlbrew/perls/5.18.2t/bin'; installsitearch='/home/ikegami/usr/perlbrew/perls/5.18.2t/lib/site_per +l/5.18.2/x86_64-linux-thread-multi'; installsitebin='/home/ikegami/usr/perlbrew/perls/5.18.2t/bin'; installsitehtml1dir=''; installsitehtml3dir=''; installsitelib='/home/ikegami/usr/perlbrew/perls/5.18.2t/lib/site_perl +/5.18.2'; installsiteman1dir='/home/ikegami/usr/perlbrew/perls/5.18.2t/man/man1' +; installsiteman3dir='/home/ikegami/usr/perlbrew/perls/5.18.2t/man/man3' +; installsitescript='/home/ikegami/usr/perlbrew/perls/5.18.2t/bin'; installstyle='lib'; installusrbinperl='undef'; installvendorarch=''; installvendorbin=''; installvendorhtml1dir=''; installvendorhtml3dir=''; installvendorlib=''; installvendorman1dir=''; installvendorman3dir=''; installvendorscript='';

    Log In?
    Username:
    Password:

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

    How do I use this?Last hourOther CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2024-04-24 18:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found