Home > Back-end >  Perl Module getting installed at wrong root dir
Perl Module getting installed at wrong root dir

Time:02-23

I am trying to update perl-DBD-Pg module but when I am trying to install that it is going to wrong root dir .

Tar file I have downloaded from CPAN and using this command to install

perl Makefile.PL INSTALL_BASE=/usr/lib64/perl5/vendor_perl

I tried using INSTALL_BASE command but it is not helping as well I have all module installed at

/usr/lib/perl5/vendor_perl/

Like this :

drwxr-xr-x.  2 root root   23 May 13  2021 Sys
drwxr-xr-x.  2 root root  142 May 13  2021 HTML
drwxr-xr-x.  8 root root  260 May 13  2021 DBI
drwxr-xr-x.  2 root root   19 May 13  2021 Readonly
drwxr-xr-x.  2 root root   34 May 13  2021 Digest
drwxr-xr-x.  3 root root   31 May 13  2021 Bundle
drwxr-xr-x.  5 root root  186 May 13  2021 DBD
drwxr-xr-x.  4 root root   86 May 13  2021 XML

But instead of getting installed at /usr/lib/perl5/vendor_perl/ it is getting installed at /usr/lib64/perl5/vendor_perl/lib/perl5/x86_64-linux-thread-multi

Basically I am trying to update my DBD perl module which is currently on version 2.19 and we have updated version available of 3.15 so I am trying to update that

CodePudding user response:

You should probably be using

PERL_MM_OPT= PERL_MB_OPT= sudo cpan DBD::Pg


First of all, you shouldn't be installing in vendor_perl.

Perl has three levels of install directories: One for modules part of Perl ("core"), one for the modules provided by the organization providing perl ("vendor"), and one for module installed by end users ("site"). Site modules override vendor modules, and vendor modules override core modules.

You should be installing into the site directory. That directory can be obtained as follows:

perl -V:installsitelib

For the perl from Ubuntu 20.04.3 LTS, that's

installsitelib='/usr/local/share/perl/5.30.0';

On to the question.

Installing a distribution installs more than just the module.

All of the following are installed into different directories:

  • Modules without build-specific components
  • Modules with build-specific components
  • Executables without build-specific components
  • Executables with build-specific components
  • Documentation for modules
  • Documentation for executables

INSTALL_BASE="$base" is a convenient way of providing all those locations at once. It's equivalent to

eval "$( perl -V:archname )"

INSTALLPRIVLIB="$base/lib/perl5"           \
INSTALLARCHLIB="$base/lib/perl5/$archname" \
INSTALLSCRIPT="$base/bin"                  \
INSTALLBIN="$base/bin"                     \
INSTALLMAN3DIR="$base/man/man3"            \
INSTALLMAN1DIR="$base/man/man1"

As you wish to use some other pattern, you will need to specify them individually.

(INSTALLARCHLIB is maybe built from INSTALLPRIVLIB if not provided?)


That said, it looks like you want to install the modules for the system-provided Perl. In that case, you should provide nothing at all.

PERL_MM_OPT= PERL_MB_OPT= ( perl Makefile.PL && make test && sudo make install )

I'd use the following, which also installs any required dependency:

PERL_MM_OPT= PERL_MB_OPT= sudo cpan DBD::Pg

The following shows to what paths files will be installed:

for n in              \
   installsitelib     \
   installsitearch    \
   installsitescript  \
   installsitebin     \
   installsiteman3dir \
   installsiteman1dir
do
   perl -V:"$n"
done

For the perl from Ubuntu 20.04.3 LTS, that's

installsitelib='/usr/local/share/perl/5.30.0';
installsitearch='/usr/local/lib/x86_64-linux-gnu/perl/5.30.0';
installsitescript='/usr/local/bin';
iinstallsitebin='/usr/local/bin';
installsiteman3dir='/usr/local/man/man3';
installsiteman1dir='/usr/local/man/man1';
  •  Tags:  
  • perl
  • Related