tags:

views:

338

answers:

6

I need to install some CPAN modules in a linux box which I do not have the root privilege.

The installation of Spreadsheet::WriteExcel goes quite smoothly. But the try to install File::Find::Rule failed with warning "you do not have permissions to install into ....." and hint "you may have to su to root to install the package"

I'm puzzled why some CPAN module installation require root privilege while there are others do not ? and If I really want to use the File::Find::Rule in that linux box , is there any work-around solution I can choose ?

thanks.

A: 

It's because some packages are installed into locations that your user doesn't have permission to write to.

My recommendation would be to get an admin to install the packages for you. I suspect there isn't a simple way to work around this.

Gordon Carpenter-Thompson
@Gordon : is there any rule that guide the module writer where should a module be depolyed and is there any flexibity that the user can choose where a module be installed ?
Haiyuan Zhang
sorry, it's not something i've ever tried. If it fails for that reason I just install it using sudo
Gordon Carpenter-Thompson
There are simple work-arounds. That is likely why this answer has been down-voted.
Brad Gilbert
+2  A: 

You probably don't have permissions to install your module to a system directory like /usr/lib. If you want to do this, you need to run the make install step with superuser permissions (su or sudo).

Alternatively, you can install a Perl module to a local directory which you have permissions for, rather than installing to the default system location. You specify the custom directory when generating the makefile.

From perlmodinstall:

gzip -dc yourmodule.tar.gz | tar -xof -
perl Makefile.PL PREFIX=/my/perl_directory
make
make test
make install
ire_and_curses
perlmodinstall is old (and now it's on my list of things to fix). Instead of PREFIX, use INSTALL_BASE.
brian d foy
And, this is a work intensive way to go about it since it doesn't handle dependencies for you. Just use `cpan .` to install from the current directory, including all of the dependencies.
brian d foy
+7  A: 

Check out local::lib for installing to other locations.

Alan Haggai Alavi
+10  A: 

Have you setup CPAN for that user to install into a directory you control?

If so, then you could be running in the differences amongst modules that use Extutils::MakeMaker (the oldest and most common build/install system), Module::Build, and Module::Install. They all have little quirks.

This is why local::lib was created. Once you have it installed and setup you shouldn't have to worry about it again (except for rogue modules that want to write things to specific places even though they have been told not to).

Chas. Owens
To elucidate, the build mechanisms can all install to local directories (that you own) rather than system directories (that are read-only because they affect all users) but the mechanisms of making them install in the new place differ. local::lib knows how to handle them all, and, as an added bonus, updates your Perl include path.
ijw
And your executable path so you can find the scripts that some modules (like Perl::Tidy) install.
Chas. Owens
+3  A: 

From perlfaq8:


How do I keep my own module/library directory?

When you build modules, tell Perl where to install the modules.

For Makefile.PL-based distributions, use the INSTALL_BASE option when generating Makefiles:

perl Makefile.PL INSTALL_BASE=/mydir/perl

You can set this in your CPAN.pm configuration so modules automatically install in your private library directory when you use the CPAN.pm shell:

% cpan
cpan> o conf makepl_arg INSTALL_BASE=/mydir/perl
cpan> o conf commit

For Build.PL-based distributions, use the --install_base option:

perl Build.PL --install_base /mydir/perl

You can configure CPAN.pm to automatically use this option too:

% cpan
cpan> o conf mbuild_arg --install_base /mydir/perl
cpan> o conf commit
brian d foy