Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Running CPAN without Being root

by batkins (Chaplain)
on Nov 02, 2003 at 22:57 UTC ( #303958=perlquestion: print w/replies, xml ) Need Help??

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

I'm distributing a script that depends on a couple non-core modules. I'd like to write a custom Makefile.PL that will automatically install those modules. If Makefile.PL is run as root, then it installs the modules properly using CPAN.pm and everything is good.

However, not all the users of the script will be able to obtain root access. For these users, I'd like to be able to install the modules into a directory that they can access. The problem is that whenever I try to make use of CPAN.pm from a non-root user, I get errors that CPAN.pm can't access /root/.cpan. I'm fairly sure that this is happening because I initially configured the CPAN module while running as root.

What I need now is to be able to use CPAN.pm as a non-root user. I mentioned this in the CB earlier, and a few people suggested that I could change that user's local CPAN config. I'd really prefer a generic method that would let this run anywhere without having to worry about messing with config files. I'd like to be able to just run Makefile.PL and have those modules installed into a user directory.

Is it possible to do this? Do I need CPANPLUS?

Replies are listed 'Best First'.
Re: Running CPAN without Being root
by Abigail-II (Bishop) on Nov 02, 2003 at 23:17 UTC
    I for one would be very irretated if a module I install by hand (that is, not by CPAN, probably for a very good reason) tried to outsmart me and started using CPAN to pull in modules. Since you cannot know how someone's CPAN is configured or what the network policies are, this is a sure way of pissing off people.

    Furthermore, you shouldn't assume perl is everywhere installed as 'root'. I seldomly install perl as root - I simply don't trust its complicated build and installation process (not to mention the dangers of CPAN) enough. I prefer having a decided account for it (which I typically call 'camel', member of the group 'perl'). I wouldn't be thrilled by a module whose Makefile says "oh, you're not root, let's install this module in some private module".

    I'd say, just add a requisite in the Makefile. If people install the module with CPAN.pm, CPAN will pick up the requirement and either automatically install, or ask to install that module, depending on the installers preference. And if the installation goes by hand, the installer wouldn't mind a message saying which modules should be installed, giving the installer the option of how to install it.

    Abigail

      True, but the prerequisite installation is interactive. Makefile.PL will first check to see if the required modules are installed. If they aren't, it will ask the user if they should be automatically installed. Also, this isn't going to be a CPAN module - it's a standalone script that happens to need some other modules.
Re: Running CPAN without Being root
by Zaxo (Archbishop) on Nov 02, 2003 at 23:10 UTC

    You can set up your own CPAN configuration by copying CPAN/Config.pm to ${HOME}/.cpan/CPAN/MyConfig.pm. Edit that to get installation locations where you have write privilege. You will typically install private modules someplace like ${HOME}/lib/perl5. See perldoc CPAN for details.

    After Compline,
    Zaxo

Re: Running CPAN without Being root
by simonm (Vicar) on Nov 03, 2003 at 17:37 UTC
    CPAN.pm accepts a conf variable, LIB, which controls the installation path. Look in the CPAN FAQ under "I am not root, how can I install a module in a personal directory?"

    More generally, take a look at ExtUtils::AutoInstall; it handles interactive querying and installation of required and/or optional modules, and you may be able to simply use it rather than writing your own interactive Makefile.PL and worrying about cross-platform testing.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2022-11-29 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?