Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have several Linux machines that run Perl programs and other programs and tools.

I want to keep all tools between machines synchronized, so I have shared the /usr/local directory between one machine (Main) and the others.

Now I would like to keep all my Perl modules and their dependencies synchronized as well in /usr/local/<path to modules>.

I have found the local::lib module, but that is intended to install modules to your home directory.

How can I set up CPAN (or CPAN alternatives) to install all modules and dependencies to one location? And how can I set up Perl on other machines to use that location to find modules?

share|improve this question
2  
You can tell local::lib where to install things. – simbabque Jan 7 at 22:07
1  
Are you hoping to install modules to be accessed from a different machine? I don't like the sound of that. – Borodin Jan 7 at 23:47
    
    
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Also see Where do I post questions about Dev Ops? – jww Jan 8 at 20:09

For our convenience, let's assign the base location to a variable: (This var isn't used by anything but the following commands. There's actually no need to export it.)

export PERL_BASE="/usr/local/perl"   # Or "$HOME" or whatever

Instruct ExtUtils::MakeMaker where to install: (This assumes $PERL_BASE doesn't include any shell metacharacters)

export PERL_MM_OPT="INSTALL_BASE=$PERL_BASE"

Instruct Module::Build where to install: (This assumes $PERL_BASE doesn't include any shell metacharacters)

export PERL_MB_OPT="--install_base $PERL_BASE"

Instruct Perl where to look for modules: (This assumes $PERL_BASE doesn't include :)

export PERL5LIB="$PERL_BASE/lib/perl5"

Instruct the system where to look for scripts: (This assumes $PERL_BASE doesn't include :)

export PATH="$PERL_BASE/bin${PATH:+:$PATH}"

Instruct the system where to look for man pages: (This assumes $PERL_BASE doesn't include :)

export MANPATH="$PERL_BASE/man${MANPATH:+:$MANPATH}"

All together:

export PERL_BASE="/usr/local/perl"
export PERL_MM_OPT="INSTALL_BASE=$PERL_BASE"
export PERL_MB_OPT="--install_base $PERL_BASE"
export PERL5LIB="$PERL_BASE/lib/perl5"
export PATH="$PERL_BASE/bin${PATH:+:$PATH}"
export MANPATH="$PERL_BASE/man${MANPATH:+:$MANPATH}"
share|improve this answer

Based on my own previous misadventures with local::lib, you should be able to set the location where modules are installed by setting INSTALL_BASE in PERL_MM_OPT, most likely by running a command similar to:

export PERL_MM_OPT='INSTALL_BASE=/usr/local/<path to modules>'

Alternately, if you're doing the Makefile/make/make test/make install process manually instead of using the CPAN toolchain, you can pass --install_base=/usr/local/<path to modules> as an argument to Makefile.PL.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.