perl DBI module installation erroring out - perl

perl DBI module installation is erroring out.
Installed perl 5.32.1 in non standard location, using -Dinstallprefix option
./Configure -Dinstallprefix=/test/user/home/perl -des
make
make test
make install
/test/user/home/perl/bin/perl -version
This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux
Set PERL5LIB env variable
export PERL5LIB="/test/user/home/perl/lib/5.32.1:/test/user/home/perl/lib/site_perl/5.32.1:/test/user/home/perl/lib/5.32.1/x86_64-linux"
which perl
/test/user/home/perl/bin/perl
Downloaded DBI-1.643 archive, after extraction execution of Makefile.PL is failing
perl Makefile.PL
Warning: PERL_LIB (/perl/lib/5.32.1) seems not to be a perl library directory
(strict.pm not found) at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Unix.pm line 1934.
Have /test/user/home/perl/lib/5.32.1/x86_64-linux
Want /perl/lib/5.32.1/x86_64-linux
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [x86_64-linux]
Config says: [x86_64-linux]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Can't stat /perl/lib/5.32.1: No such file or directory
at Makefile.PL line 280.
Can't stat /perl/lib/5.32.1/x86_64-linux: No such file or directory
at Makefile.PL line 280.
Failed to opendir '/perl/lib/5.32.1/x86_64-linux/CORE' to find header files: No such file or directory at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Any.pm line 3048.
Found non existing paths are referred from #INC
perl -e "print \"#INC\""
/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
Can someone guide me where from #INC getting these non existing paths
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
are there any way to restrict #INC to append non existing paths?

I think you want just -Dprefix=/.... There are other things that need to end up in the right place too. You shouldn't need to set PERL5LIB though because perl should be using your prefix as its default #INC. What does your perl -V show?
There is an installprefix, but it's aimed at compiling on one machine and installing on another. However, the INSTALL docs also recommend against using that. Is that what you are trying to do?
As for the other directories, the INSTALL docs describe the various directories that show up in #INC.

Thank you #brian for pointing me in right direction.
Following was the root cause behind #INC contains non existing directories.
Last time during perl installation at least one time I ran following command
./Configure -des -Dprefix=/perl
Use relocatable #INC? [n]
Pathname where the private library files will reside? (~name ok)
[/perl/lib/5.32.1]
Where do you want to put the public architecture-dependent libraries? (~name ok)
[/perl/lib/5.32.1/x86_64-linux]
Pathname for the site-specific library files? (~name ok)
[/perl/lib/site_perl/5.32.1]
Pathname for the site-specific architecture-dependent library files? (~name ok)
[/perl/lib/site_perl/5.32.1/x86_64-linux]
then executed make command. Later on make test failed for other error.
Then without running make distclean command, I re ran Configure with
-Dinstallprefix option
./Configure -Dinstallprefix=/test/user/home/perl -des
This populate #INC as follows
/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
To fix this issue executed following steps,
make distclean
./Configure -des -Dprefix=/test/user/home/perl -Dusethreads
now #INC is populated correct
#INC:
/test/user/home/perl/lib/site_perl/5.32.1/x86_64-linux-thread-multi
/test/user/home/perl/lib/site_perl/5.32.1
/test/user/home/perl/lib/5.32.1/x86_64-linux-thread-multi
/test/user/home/perl/lib/5.32.1
Now DBI installation ran successfully.

Related

Tcl call in perl script

I am executing a Perl script that makes use of use Tcl;. This currently invokes tcl8.4.
When I check my lib path, tcl8.5 is also found. I want use Tcl; to use tcl8.5 instead of tcl8.4. Can any one help me please?
From looking at the distro's Makefile.PL, I believe it uses a tclshX.Y found when the module is installed.
If a newer version 8.5 of Tcl has been installed since you installed the module, you could try to reinstall the module.
wget https://cpan.metacpan.org/authors/id/V/VK/VKON/Tcl-1.27.tar.gz
tar xvzf Tcl-1.27.tar.gz
cd Tcl-1.27
perl Makefile.PL
make test
make install
If that isn't sufficient, this module's Makefile.PL accepts arguments that help locate the correct tclsh. As mentioned in the distro's README file, you can see the accepted options using the following:
perl Makefile.PL --help

Package all Perl module dependencies?

I've found myself on CentOS without root access, and with a very lame Perl that doesn't even have ExtUtils::MakeMaker.
Does there exist something that could produce an archive of a module's dependencies, for my to unwrap into a directory that I could put into #INC?
use App::cpanminus
cd ~/bin
curl -LO http://xrl.us/cpanm
chmod +x cpanm
export ROOT=/some/directory
export PERL5LIB=${ROOT}/lib/perl5
Then, install ExtUtils::MakeMaker and Module::CoreList. You can't do a simple installation because these modules are used by cpanm, and it doesn't look in the unpacked source directory for them. So, get cpanm to download them, and do a semi-manual install. It actually installs three distributions (the above two and ExtUtils::Install), which is why you get to invoke the build mantra three times:
PERL_MM_OPT=INSTALLBASE=$ROOT ./cpanm -L $ROOT --look ExtUtils::MakeMaker Module::CoreList
perl Makefile.PL
make && make install
exit
perl Makefile.PL
make && make install
exit
perl Makefile.PL
make && make install
exit
It unpacks and cds into each distribution's directory successively. At least that's what happens on a bare-bones CentOS 6 install I just happen to have lying around.
After that, you should be able to install your module and its dependencies via
./cpanm -L $ROOT <module name, or url, or tarball goes here>
Look at the cpanm docs for more info.
You could use perlbrew to innstall a full new Perl with user access.
http://perlbrew.pl/
#install perlbrew
wget -O - http://install.perlbrew.pl | bash
# install new perl for youurself
perlbrew install perl-5.16.0
# set aliases
perlbrew switch perl-5.16.0
#reinstall all moodules for new perl http://perlbrew.pl/Reinstall-All-Modules-On-New-Perl.html
perlbrew list-modules | perlbrew exec --with perl-5.16.0 cpanm
#how to install/recompile third party modules
https://github.com/lecstor/DevNotes/wiki/Image-Magick-with-Perlbrew
Regards,
Download and untar ExtUtils::MakeMaker, create a directory lib under your home directory, install via:
perl Makefile.PL PREFIX=~/lib LIB=~/lib
Now that module is installed I suggest you use local::lib (easy install via the bootstrap method in the documentation) to install modules:
perl -MCPAN -Mlocal::lib -e 'CPAN::install(MIME::Lite)' # Replace MIME::Lite with what you want to install.
Here MIME::Lite gets installed via cpan to your local lib directory.
Prelbrew won't take long to set up, and you likely have an easier time of things in the long run.
Edit, too long for comment.
#LeeGee Perhaps I wasn't specific enough.
The method described will allow you to get around the restricted version of perl you have access to, and allow installaton of modules to another location.
If you want to package your app on another machine you could use either PAR or pp to create a standalone package of code & modules, or a stand alone executable.
Failing that Module::ScanDeps will find a scripts dependencies

net-ssh2 installation in linux

I am trying to install Net-SSH2 in linux server and it is asking for lots of dependencies.
I installed both libssh2 and openssl, but still it throws the follwoing error.
/opt/script/Net-SSH2-0.52/assertlibcssKKx3q: error while loading shared libraries: libssh2.so.1: cannot open shared object file: No such file or directory
wrong result: 'ssh2'
Can someone tell me whats happening here?
Please find below the installation log
[root#vm Net-SSH2-0.52]# perl Makefile.PL
Subroutine checklibs redefined at inc/Module/Install/CheckLib.pm line 11.
Subroutine assertlibs redefined at inc/Module/Install/CheckLib.pm line 25.
Subroutine _author_side redefined at inc/Module/Install/CheckLib.pm line 39.
The libssh2 library is required by this module. If you don't have it, you can
download it from http://www.libssh2.org; you may also need OpenSSL, which can be
obtained from http://www.openssl.org, or libgcrypt, which can be obtained from
http://www.gnupg.org.
Debian: sudo aptitude install libssh2-1-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel
You can pass your libssh2 lib and include dirs on the command line. E.g.:
perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include
To build with libgcrypt instead of OpenSSL, pass 'gcrypt' as a parameter to
Makefile.PL, e.g.:
perl Makefile.PL gcrypt
If you want to build on Windows, see the file BUILDING.WIN32 in the
distribution.
/opt/leo/perlscript/Net-SSH2-0.52/assertlibjmyXurmJ: error while loading shared libraries: libssh2.so.1: cannot open shared object file: No such file or directory
wrong result: 'ssh2'

Manual installation of a Perl Module

I have downloaded the module Digest::SHA1 and extracted it to a directory (../Digest-SHA1-2.13/) , then copied all the SHA1.* files into (../Digest-SHA1-2.13/Digest)
and in the perl script, I did : use Digest::SHA1;
launching the script like this:
perl -I ../Digest-SHA1-2.13/Digest perlscriptname.pl
I get this error:
Can't locate loadable object for module Digest::SHA1 in #INC
I assume it has something to do with a shared library (*.so)?, I have no idea how to continue from here.
I can install it directly using CPAN (-MCPAN) module, as I dont have permissions on that server to do that, and can install only locally (where the application is running).
My final goal is to use Algorithm::CouponCode which is dependent on Digest::SHA1
The weird part is, that I have Digest::SHA1 installed (perl -MDigest::SHA1 -e 'print $Digest::SHA1::VERSION' shows version 2.11), still Algorithm::CouponCode (which is installed the same way I did with Digest::SHA1) complains it can find it in #INC
thanks!
Use this recipe for manually installing perl modules:
tar zxf Digest-SHA1-2.13.tar.gz
cd Digest-SHA1-2.13
perl Makefile.PL
make
make test
make install
Note that some distributions will have a Build.PL file instead of Makefile.PL. In that case use this recipe:
tar zxf ...
cd ...
perl Build.PL
./Build
./Build test
./Build install
(You may be able to get by with just running make install and ./Build install.)
If you need to alter the installation dir then use:
perl Makefile.PL INSTALL_BASE=...
or
perl Build.PL --install_base ...
depending on the kind of module.
For more info see the perldoc for ExtUtils::MakeMaker::FAQ and Module::Build
There are two kinds of Perl module: pure-Perl and XS. Pure-Perl modules are written entirely in Perl, and can usually be installed just by copying the .pm files to an appropriate directory. XS modules are written in both Perl and C (XS is processed into C code by the ExtUtils::ParseXS module) and require a C compiler to install them.
As dsolimano said, the easiest way to install Perl modules for the system Perl when you don't have root access is to use local::lib. (You could do the same things that local::lib does yourself, but why bother?)
The reason why Digest::SHA1 works by itself but not when you're using Algorithm::CouponCode is that the system Perl already has version 2.11 of Digest::SHA1 installed. When you use -I ../Digest-SHA1-2.13/Digest, then use Digest::SHA1 picks up the Perl code from ../Digest-SHA1-2.13/Digest, but the shared library that would be built from the XS code is not in the corresponding location.
Any reason why you can't use local::lib?
create and use a local lib/ for perl modules with PERL5LIB
It is basically a tool to help you use a private (non-systemwide) directory as your Perl library directory.
After setting it up, you could run a command like
perl -MCPAN -Mlocal::lib -e 'CPAN::install(Algorithm::CouponCode)'
and then your script would use your locally installed copy of Algorithm::CouponCode).

Can't locate in #INC during CPAN dependency install performed not as root

While trying to do:
perl -I'/v1/data/site_perl' -MCPAN -e 'install Log::Dispatch';
I continue to get "Can't locate Params/Validate.pm in #INC." When looking at the output, /v1/data/site_perl is NOT in the #INC displayed, even though I used -I.
I am not root so I have changed my CPAN config so that:
'makepl_arg' => q[LIB=/v1/data/site_perl INSTALLSITEMAN1DIR=/v1/data/site_perl/man/man1 INSTALLSITEMAN3DIR=/v1/data/site_perl/man/man3 INSTALLMAN1DIR=/v1/data/site_perl/man/man1 INSTALLMAN3DIR=/v1/data/site_perl/man/man3]
So even LIB is set.
In a basic script I have:
use lib '/v1/data/site_perl';
use Params::Validate;
With no problems.
How do I make the Log::Dispatch use lib /v1/data/site_perl without a force install? What am I missing?
I believe CPAN.pm likes to call a lot of sub-processes for various tasks, and these end up starting new perls, which will not inherit your -I flag. Instead, try setting a PERL5LIB environment variable, e.g.
PERL5LIB='/v1/data/site_perl' perl -MCPAN -e 'install Log::Dispatch'
Another strategy to consider is to simply build a complete Perl installation in your local directory -- then use that perl's CPAN utilities. They will already have all your own paths built-in. This is the way I tend to do it.
You cannot install into a different CPAN directory using a simple -I flag. You can use the local::lib package to install a local set of libraries, or see this question and this question.