Mar 20

Install cpan on a server without root access

Category: Linux   — Published by tengo on March 20, 2008 at 3:31 am

As you can see from reading this discussion, installing a cpan module, without root access, can be daunting. When you managed to install your own compiled Perl on a non-root account, this is in most cases earlier or later the next step/problem. Do this:

login via ssh
ssh -l myusername

Mostly, follow this guide from the CPAN FAQ:

"How do I manually install a module in a private/non-standard directory?

You need to set PREFIX and LIB when you run the Makefile.PL. LIB is where the module files will go and PREFIX is the stub directory for everything else. For example:

  foo@barbell$ perl Makefile.PL LIB=/home/foobar/mylib PREFIX=/home/foobar/mylib"

That should work and you should stop reading now.
(If you set only PREFIX or only LIB, CPAN might end up trying to install parts with a prefix, and for example other parts, like man3, into the default... Possible errors include "Do not have write permissions on '/usr/local/bin'" or "ERROR: Can't create '/usr/local/man/man3'")

Still, if you'd like to sort of emulate what the above does, go on and create these directories:


then start your perl and cpan

path/to/my/perl -MCPAN -e 'shell'

in cpan enter:

cpan> o conf makepl_arg "LIB=/path/to/myperl/lib \
INSTALLMAN1DIR=/path/to/myperl/man/man1 \

the best thing to do is to copy in these lines via [CTRL]+[SHIFT]+[V] and after that remove all wrong newlines

cpan> o conf commit

sets this conf default for the future

After that, installing things like Bugzilla is simple:

install Bundle::Bugzilla

just remember to define the path to your libs in scripts

use lib "/path/to/lib/";

If you're still having problems

If all of this didn't help you. Or if some Modules are especially demanding and a bit of a pain to get working under this config, try this:

Make sure you have the latest CPAN running. You might also install it under your userspace ~/perl path, and then execute it with ~/perl/bin/cpan.

Have a look at your .bashrc and your and make sure they are working well together. Watch the "installing..." lines thrown at you by cpan on non-installing modules, so you see where everything ends up.

See how cpan behaves when you install a module, with OK at the end, and then - what it does if you try installing it again. Does it reinstall or tell you "it's up to date"? - which would be right.

If you have PREFIX and LIB configured in your, make sure that you understand that prefix should be =/perl while LIB would then be =/perl/lib - prefix is prepended in front of everything: lib, man, man/man3 etc.

If everything else fails, a "forced" module install might get over any warning and install stubborn modules.

2 Responses to “Install cpan on a server without root access”

  1. David Chambers says:

    Your "install your own compiled Perl on a non-root account" link needs to be updated to reflect the post's new location.

  2. David Chambers says:

    Your "install your own compiled Perl on a non-root account" link needs to be updated to reflect the post's new location.