5

As with many people whose sites are hosted on shared servers, I do not have root access, and the hosting company will not install Perl modules at the request of users.

Unfortunately, I also do not have write privileges to the ~/ folder, only to certain subfolders (such as ~/cgi-bin/).

I've attempted the solution suggested here, changing ~/perl5 to ~/cgi-bin/perl5 (which I created), but I keep getting this error:

"Can't write to cpanm home '~/.cpanm': You should fix it with chown/chmod first."

The problem is, as I stated, I don't have write privileges to ~/.

Is there some way to tell the installer to use ~/cgi-bin/.cpanm instead? I've tried to figure it out by searching on here and elsewhere on the internet, but I'm starting to bash my head against the wall.

EDIT : So I've tried the suggestion by Steven below, using this command:

HOME=$HOME/cgi-bin cpanm local::lib

Now, cpanm successfully runs and tries to install the module, but has numerous warnings throughout the installation and ultimately fails (presumably something is still trying to write to a forbidden folder??).

Here are some sample warnings:

Warning: prerequisite CPAN 1.82 not found. We have 1.7601.

Warning: prerequisite ExtUtils::Install 1.43 not found. We have 1.32.

Warning: prerequisite ExtUtils::MakeMaker 6.42 not found. We have 6.17.

Warning: prerequisite Module::Build 0.36 not found.

Warning: You do not have permissions to install into /usr/lib64/perl5/5.8.5/x86_64-linux-thread-multi at /usr/lib/perl5/5.8.5/ExtUtils/Install.pm line 114.

mkdir /usr/lib/perl5/5.8.5/App: Permission denied at /usr/lib/perl5/5.8.5/ExtUtils/Install.pm line 176

make: *** [pure_perl_install] Error 255

Community
  • 1
  • 1
WinnPh
  • 91
  • 1
  • 5
  • http://stackoverflow.com/questions/540640/how-can-i-install-a-cpan-module-into-a-local-directory – edem Jan 23 '13 at 17:20
  • 1
    That question is related (though not precisely the same), but I run into the same "permission denied" error for ~/.cpan or ~/.cpanm, even when I specify a different INSTALL_BASE directory. – WinnPh Jan 23 '13 at 17:52
  • 2
    How come this question is closed? And even if it is why for `off topic`? How is this question `off topic`? You should explain before clicking on close. –  Jan 24 '13 at 10:43
  • [off topic](http://stackoverflow.com/faq#close) Questions on Stack Overflow are expected to relate to programming or software development within the scope defined in the FAQ. **Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope.** Read more about closed questions here. –  Jan 24 '13 at 10:54
  • How is the question off topic? It is definitely a practical, answerable question about popular software for developers. – reinierpost Mar 19 '13 at 15:49

1 Answers1

1

~ is just a shorthand way of accessing the environment variable $HOME, so you should be able to do something like export HOME=$HOME/cgi-bin to move your effective home directory down into some directory you have write permissions for. This will affect many things, however, so be careful.

Chris Dodd
  • 119,907
  • 13
  • 134
  • 226
  • Yeah, that sounds pretty dangerous to me, I would much rather somehow pass this subdirectory to cpanm via the command line. But it's definitely something to consider as a last resort. – WinnPh Jan 23 '13 at 17:58
  • 3
    If you prefix the command with HOME=$HOME/cgi-bin e.g. HOME=$HOME/cgi-bin cpanm ... then your home is only reset for that command. – Steven Jan 23 '13 at 19:46