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

Hello All, I am learning perl now and thus far I like it. Though I noticed that cpan is not as pretty as I thought it was..

I noticed that cpan tries to compile a package doing make, make install and thus need root privs. Though, I run cpan in User all the time and thus can't build. After looking around, I found out that most people use sudo. But since of security reasons I don't want to use sudo (I wrote a sudoWorm to demostrade the dangers of sudo and thus I would be a bit of a Hypocrite to use sudo myself heh)

Anyway isn't there a way to run su -c "make install" instead? I don't mind I have to enter my root passwd for the install of a Module. I tried to run cpan as root. But that didnt really work nice either. Since I got quite a lot of rubbish. I have to configure it all the time every time I want to use it..

Oh and I build some packages myself with just going to the Folder and do make install myself. But I forgot to do the Deps. and now I am stuck with a package that doesnt work not wants to resolve it deps for me.. Any tips for me? Thanks!

But besides this big annoyance Perl give me a lot of spare time. Everything I used to do in C or ASM that took me like 20 Minutes take 2 Minutes now :) Thanks Perl ^^

Found it thanks !

Replies are listed 'Best First'.
Re: Perl Cpan Question
by moritz (Cardinal) on Feb 08, 2009 at 21:33 UTC
    I can't answer your question, but maybe I can offer you alternatives
    • Don't install CPAN packages directly, but build binary packages for your linux/unix system. For Debian you can use dh-make-perl, there are other tools for other distributions. The version in Debian Lenny nicely follows dependencies.
    • Make the locations to which cpan installs stuff writable for a user named cpan, and run cpan as that user. (Heard from JavaFan on the CB the other day).
Re: Perl Cpan Question
by Anonymous Monk on Feb 08, 2009 at 21:54 UTC
    http://sial.org/howto/perl/life-with-cpan/non-root/

    You should peruse the excellent docs there to learn about installing CPAN modules as a non-root user. Furthermore, the rest of the site has excellent information about general CPAN usage!
Re: Perl Cpan Question
by Anonymous Monk on Feb 08, 2009 at 21:56 UTC
    and thus need root privs.
    CPAN only needs root privs if its/perl are configured to install in root owned directories. There is no reason it has to be root owned. CPAN non-root questions
Re: Perl Cpan Question
by locked_user sundialsvc4 (Abbot) on Feb 09, 2009 at 06:23 UTC

    When Perl “looks for a package,” it refers to a “@USE list” and marches down that list in-order.

    As you'll see from the Perl documentation (and I don't mean that as “RTFM!”) there are several ways that the content of that list can be influenced.

    Also, when you use CPAN, there are a set of settings (accessible via o conf which determine where CPAN looks, what settings it uses, where it places files, and so-on.

    You can, in fact, influence everything about Perl. One of the most-common situations where you do that is when you're deploying Web-server packages ... “you don't own the hardware,” and “every one of your customers' web-sites are different.” Perl can handle this quite easily. You tell CPAN to install into a site-specific location, and you (e.g. via the PERL5LIB variable...) tell Perl where to look.

    But hey, we all admit it, “it's not immediately obvious how it works.” Perservere. And ask questions here... freely. You're among friends.

Re: Perl Cpan Question
by missingthepoint (Friar) on Feb 09, 2009 at 03:30 UTC
    But since of security reasons I don't want to use sudo

    Well, then don't. What's stopping you running su -c cpan, configuring it, and thereafter installing all modules with su -c "cpan Foo::Bar"?

    I tried to run cpan as root ... I have to configure it all the time every time I want to use it

    Then you have a separate problem. Whether you su -c or sudo, what's run is run with uid 0. It sounds like CPAN isn't saving its config in root's home dir properly, so it asks to be reconfigured each time.


    Life is denied by lack of attention,
    whether it be to cleaning windows
    or trying to write a masterpiece...
    -- Nadia Boulanger
Re: Perl Cpan Question
by tinita (Parson) on Feb 09, 2009 at 13:56 UTC
    Anyway isn't there a way to run su -c "make install" instead?
    The answer is right there in the CPAN documentation: http://search.cpan.org/~andk/CPAN-1.9301/lib/CPAN.pm
    search for sudo. set the mentioned variables make_install_make_command and mbuild_install_build_command to the values which are suggested there and the install will be called with sudo.
Re: Perl Cpan Question
by leocharre (Priest) on Feb 09, 2009 at 13:55 UTC
    Just install modules as root.

    poor man's cpan configuration follows...

    If cpan has not been run before, there's a set of questions.
    The first I think is if to save (say yes)
    Then some questions like
    path to ncpftp [] ?
    For all those, press enter

    You may be asked if you want to set a timeout for interactive bla bla, set it to like 30 or so (seconds).
    If you don't set one and you install a module that asks you something before install, it just hangs until you say something.

    Then you get to a list of servers, listed
    1 servername
    2 servername
    3 servername
    ...

    Selected two or three, like
    12 enter
    5 enter
    3 enter

    then enter again (with nothing as input) to continue

    if when we started you selected to save (or something to that extent) you won't ever be asked these questions again when you run cpan

    This is all saved to a conf file in ~/.cpan/CPAN/MyConfig.pm or something like that.

    So it can be edited by text at any moment (the options you selected).