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

I need to install a Perl module on my web host's server. I don't have admin permissions so I want to install it in my local directory. I chose "local::lib" when setting up cpan. But when I try and install any module I get an error during the "manify" process.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! ERROR: Can't create '/usr/local/man/man3' mkdir /usr/local/man/man3: Permission denied at /home/slugger415/.cpan +/build/ExtUtils-MakeMaker-7.30-3oX26_/blib/lib/ExtUtils/Install.pm li +ne 477. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! at -e line 1. make: *** [pure_site_install] Error 13 HAARG/local-lib-2.000024.tar.gz /usr/bin/make install -- NOT OK

Is there a param I need to specify to make it install in my home directory? It doesn't even let me install local::lib. I looked at http://www.cpan.org/modules/INSTALL.html but didn't see anything about it.

Thank you.

Replies are listed 'Best First'.
Re: How to install Perl modules locally on Unix?
by haukex (Archbishop) on Nov 26, 2017 at 16:06 UTC

    Try using "The bootstrapping technique" from the local::lib docs to install that module. I recently used this on a host without admin rights and without an existing local::lib installation and I don't remember having any trouble. Afterwards I used cpanm -l ~/perl5 Module::Name to install modules there and it worked fine (Update: IIRC the -l ~/perl5 was necessary because I hadn't yet set up the environment variables at that point). In fact, here's a copy-and-paste from the .bash_history with a few irrelevant commands removed:

    wget http://search.cpan.org/CPAN/authors/id/H/HA/HAARG/local-lib-2.000 +024.tar.gz tar xzvf local-lib-2.000024.tar.gz cd local-lib-2.000024 perl Makefile.PL --bootstrap make test && make install cd .. rm -rf local-lib-2.000024* cpanm -l ~/perl5 ...

    While you should set up the environment variables in .bashrc/.cshrc as described in the local::lib docs, your web server will almost certainly disregard those. IMO it's often easiest to just specify an absolute pathname in your CGI script via use lib '/path/to/modules';, but whether that's always the best approach depends on your circumstances (like in case this script is being deployed on different hosts with different directory structures).

    cpanm happened to already be installed there, but in case it isn't, it also has a simple installation option: curl -L https://cpanmin.us | perl - App::cpanminus (see App::cpanminus).

    A few edits for clarity.

      Thank you for the suggestions and instructions. I was able to install local::lib in my home directory, but don't have cpanm and though I tried to install it with cpan install I still can't get it to run.

      -bash: cpanm: command not found
        I was able to install local::lib in my home directory,

        Did you set up the environment variables as described in the local::lib docs? For example, for bash, the docs suggest: echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"' >>~/.bashrc

        Note that you have to log out and log back in once for this to take effect.

        but don't have cpanm

        Did you try the installation command I showed from the App::cpanminus docs (after setting up the environment vars)? That is: curl -L https://cpanmin.us | perl - App::cpanminus

Re: How to install Perl modules locally on Unix?
by Anonymous Monk on Nov 27, 2017 at 13:42 UTC
    Also Google the topic of "installing Perl on shared hosting."