Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

best way to install modules in your home directory?

by pc88mxer (Vicar)
on May 25, 2008 at 19:55 UTC ( #688433=perlquestion: print w/ replies, xml ) Need Help??
pc88mxer has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering what's the best practice to use when you want to install CPAN modules in your own 'lib' directory.

I am running into problems when I want switch between installing modules in a private directory and installing them (as root) in the system locations. Specifically, I get root-owned files in my home build directory which are a nuisance.

Even as a normal user I can see the utility in being able to easily switch between different CPAN configurations. For instance, different application may each have their own 'lib' directory and hence their own CPAN install configuration.

What's a good way to manage this problem?

Comment on best way to install modules in your home directory?
Re: best way to install modules in your home directory?
by moritz (Cardinal) on May 25, 2008 at 19:59 UTC
    The first half of your problem can be solved by not using sudo, but really become root (su -). Then root will use his own home directory.

    An even better solution is not to install anything with cpan directly, but build a package that is native to your operating system. For Debian dh-make-perl is really useful, and very good usable in Testing (aka Lenny), I'm sure there are similar utilities for other distributions and Unixes (for example cpan2dist from CPANPLUS).

      Gentoo has g-cpan (http://www.gentoo.org/proj/en/perl/g-cpan.xml) which takes a CPAN package and wraps an ebuild around it. Thus all packages installed that way are manageable via portage.
Re: best way to install modules in your home directory?
by rafl (Friar) on May 25, 2008 at 19:59 UTC

    I use local::lib or a perl installed into the home directory to do that.

Re: best way to install modules in your home directory?
by ysth (Canon) on May 25, 2008 at 20:15 UTC
    I am running into problems when I want switch between installing modules in a private directory and installing them (as root) in the system locations. Specifically, I get root-owned files in my home build directory which are a nuisance.
    That doesn't seem like a necessary problem to be having...what exactly are you doing to cause it?
Re: best way to install modules in your home directory?
by psini (Deacon) on May 25, 2008 at 20:26 UTC

    I agree with morris and would like to add a "rule 0": try and use modules that are already packaged in your distro.

    I myself use Debian stable and in more than 4 years I needed only twice a module not deb-packaged. CPAN has an incredible number of modules, often redundant or overlapping and, if you search only in the modules supported by your distro, chances are high that you'll find something apt.

    Rule One: Do not act incautiously when confronting a little bald wrinkly smiling man.

      I agree that pre-packed modules should be used first (in fact I thought this was self-evident and not worth mentioning), but this...
      I myself use Debian stable and in more than 4 years I needed only twice a module not deb-packaged.

      ... mostly shows that you don't run foreign code very often. (Or under-use CPAN).

      Want to run a jifty application? Need to build and install about 15 more Debian packages. Tired of HTML::Template and want to try HTML::Template::Compiled? Build a new .deb. Heck, not even Text::Table is in Debian.

      Many recently updated modules also depend on minimum versions of others that are too old in Debian.

      During using Debian Etch I assembled a collection of nearly 100 perl modules packed up as Debian modules. And I fear the upgrade to Lenny, because it introduces perl-5.10.0, breaking many of these modules ("breaking" here means that I have to recompile them).

      So what I'd really want to see is a CPAN mirror that automatically builds debian packages out of new modules, and places them into a local Debian mirror. Any takers? ;-)

Re: best way to install modules in your home directory?
by dragonchild (Archbishop) on May 25, 2008 at 20:46 UTC
    Use Perl::Install and then each Perl has its own modules. Perl doesn't have to be installed by root to be usable. My working Macbook has a case-sensitive partition at /Volumes/Dev and, in there, there's a perl/ directory. It was installed by my user, so I can just run 'cpan' directly and it just works.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: best way to install modules in your home directory?
by Corion (Pope) on May 25, 2008 at 20:48 UTC

    I think you're doing something wrong if you need to switch to root just to locally install a module into a directory you (as a user) should have write permissions to.

    Personally, I wouldn't run any "special" applications using the system Perl, because using the system Perl couples your application and the system together into one upgrade cycle. I use my own private Perls installed under /opt/perl/ and compile all modules needed for my applications for them.

    My golden rule for messing with the system Perl is: Everything that goes into the system Perl also needs to come from your vendor. For Linux, this means that you should only install modules for the system Perl using the distribution package manager. Everything else will break not only your application but also many other system utilities in the long run, because vendors and distributions like to meddle by applying small changes to stuff, which tend to get overwritten when installing other stuff from CPAN.

Re: best way to install modules in your home directory?
by rovf (Priest) on May 26, 2008 at 09:15 UTC
    May I ask why you install the modules as root, if you want to have them in your private directory? For modules I only want to have under my $HOME, i don't call 'cpan' as root, so it doesn't happen that the installed modules end up root-owned....
    -- 
    Ronald Fischer <ynnor@mm.st>
Re: best way to install modules in your home directory?
by Bloodnok (Vicar) on May 26, 2008 at 15:34 UTC
    Hi ,

    If ever I need to install any modules created using h2xs e.g. CPAN modules, in other than the default location, the first step i.e. when generating the makefile, is to use the PREFIX macro. In your case ...

    perl Makefile.PL PREFIX=$HOME

    Note that, if it didn't already exist, running make install will create $HOME/lib

    HTH

    At last, a user level that best describes my experience :-))
Re: best way to install modules in your home directory?
by Anonymous Monk on May 27, 2008 at 19:09 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://688433]
Approved by moritz
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2014-09-23 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls