How to install CPAN module in local directory?

I use a hosted Linux machine, so I do not have write permissions to the /usr/lib directory.

When I try to install the CPAN module by doing the usual:

 perl Makefile.PL make test make install 

This module is extracted to the blib/lib/ folder. I saved use blib/lib/ModuleName , but it still compiler says that the module could not be found. I tried copying the .pm file to a local directory and saved the require ModuleName , but still this gives me some error.

How can I install the module in another directory and use it?

+56
module perl install cpan
Feb 12 '09 at 9:41
source share
5 answers

I had a similar problem when I couldn’t even install local :: lib

I created an installer that installed the module somewhere regarding .pl files

Installation is as follows:

 perl Makefile.PL PREFIX=./modulos make make install 

Then in the .pl file, which requires the module that is located. /

 use lib qw(./modulos/share/perl/5.8.8/); # You may need to change this path use module::name; 

The remaining files (makefile.pl, module.pm, etc.) do not require changes.

You can call the .pl file with

 perl file.pl 
+33
Feb 12 '09 at 10:57
source share

Other answers are already on Stackoverflow:

  • How to install modules locally without root access ...
  • How can I use the new Perl module without installation permission?

From perlfaq8:




How to save your own catalog of modules / libraries?

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

For distributions based on Makefile.PL, use the INSTALL_BASE parameter when creating the Makefile:

 perl Makefile.PL INSTALL_BASE=/mydir/perl 

You can set this in the CPAN.pm configuration so that the modules are automatically installed in your private library when using 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 also configure CPAN.pm to automatically use this option:

 % cpan cpan> o conf mbuildpl_arg '--install_base /mydir/perl' cpan> o conf commit 
+59
Feb 12 '09 at 23:02
source share

local :: lib will help you. He will convince make install (and Build install) to install into a directory where you can write, and he will tell perl how to get these modules.

In general, if you want to use the module located in the blib / directory, you want to say perl -Mblib ... , where ... is the way you usually invoke your script.

+19
Feb 12 '09 at 10:21
source share

I highly recommend Perlbrew . It allows you to run several versions of Perl, install packages, hack the internal components of Perl, if you want, all the usual user permissions.

+3
Aug 31 '13 at 12:10
source share

For distributions based on Makefile.PL, use the INSTALL_BASE parameter when creating the Makefile:

 perl Makefile.PL INSTALL_BASE=/mydir/perl 
+2
Jul 19 '14 at 8:34
source share



All Articles