Perl : can't install dependency using cpan - perl

I have a scsript that uses package LWP::Curl
But when I try to install it using this command [sudo cpanm install LWP::Curl] get the following error :-
Fetching http://www.cpan.org/authors/id/S/SY/SYP/Net-Curl-0.37.tar.gz
-> OK
Unpacking Net-Curl-0.37.tar.gz
Entering Net-Curl-0.37
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker::Config 0 ... Yes (6.66)
Configuring Net-Curl-0.37
Running Makefile.PL
pkgconfig failed:
Can't locate ExtUtils/PkgConfig.pm in #INC (you may need to install the ExtUtils::PkgConfig module) (#INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at Makefile.PL line 39.
Using curl-config script.
Can't exec "curl-config": No such file or directory at Makefile.PL line 212.
curl-config failed:
Execution curl-config --vernum failed.
is your libcurl installed correctly ?
libcurl development files do not seem to be available
You must install libcurl 7.15.5 or newer to
build this module
NA: Unable to build distribution on this platform.
-> N/A
-> FAIL Configure failed for Net-Curl-0.37. See /home/harsh/.cpanm/work/1460968559.18563/build.log for details.
I am new to Perl , How can this be resolved?

Sounds like a bug in the Net::CURL package and it fails to list its dependencies correctly.
Install ExtUtils::PkgConfig first (just like the error message says).
Then install libcurl (the -dev version if your platform distinguishes between that and the base package) using your platform's package management system (again, like the error message says).

Related

Installing Perl Module in specified directory

I am trying to install one of the Perl module in my server (ubuntu droplet from Digital Ocean). I wanted this module to be installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/ directory which I have already created.
This is specific to one module. I don't want to install it in default path like /usr/bin/perl. I wanted it to be installed in above mentioned path.
Here are the list of commands which I executed to install the Email::Reply perl module.
Downloaded module from metacpan
tar xvfz Email-Reply-1.204.tar.gz
cd Email-Reply-1.204/
perl Makefile.PL PREFIX=/home/vinod/my_test_folder/perl_practice/scripts/lib/
su
<password_for_root>
make
make test
make install
When I execute make install command the following output got displayed on terminal screen
Manifying 1 pod document
Installing /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/Email/Reply.pm
Installing /home/vinod/my_test_folder/perl_practice/scripts/lib/man/man3/Email::Reply.3pm
Appending installation info to /home/vinod/my_test_folder/perl_practice/scripts/lib//lib/x86_64-linux-gnu/perl/5.26.1/perllocal.pod
And I could see the module got installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/Email/Reply.pm path, which is not right path which I mentioned in PREFIX=.
Strange thing here I wrote one small script which uses Email::Reply module by mentioning module path in shebang line
Code below:
#!/usr/bin/perl -I/home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/
use EMail::Reply;
print "Hi\n";
still its throws an error
Can't locate EMail/Reply.pm in #INC (you may need to install the EMail::Reply module) (#INC contains: /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/ /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at test.pl line 3.
BEGIN failed--compilation aborted at test.pl line 3.
I want this module to be installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/
How to achieve this. Please help me.
This is what local::lib can be used for, and cpanm supports it by default:
$ cpanm -l /home/vinod/my_test_folder/perl_practice/scripts Email::Reply
This will install it to /home/vinod/my_test_folder/perl_practice/scripts/lib/perl5.
Alternatively you can recreate the options local::lib sets for this case, the important one for this case is PERL_MM_OPT.
$ env PERL_MM_OPT='INSTALL_BASE=/home/vinod/my_test_folder/perl_practice/scripts' cpanm Email::Reply
Importantly, note that all of this is case sensitive, you must use Email::Reply;.

Which modules are missed?

On my system:
$ uname -ra
Linux web.feel-safe.net 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux
I get next errors while installing modules:
Can't locate inc/ExtUtils/MY_Metafile.pm in #INC (you may need to install the inc::ExtUtils::MY_Metafile module) (#INC contains: /home/feelsafe/web/local/lib/perl5/x86_64-linux-gnu-thread-multi /home/feelsafe/web/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at Makefile.PL line 4.
BEGIN failed--compilation aborted at Makefile.PL line 4.
.
Configuring List-MoreUtils-0.416
Running Makefile.PL
Can't locate inc/latest.pm in #INC (you may need to install the inc::latest module) (#INC contains: /home/feelsafe/web/local/lib/perl5/x86_64-linux-gnu-thread-multi /home/feelsafe/web
/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/per
l/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at Makefile.PL line 51.
BEGIN failed--compilation aborted at Makefile.PL line 51.
.
Configuring MRO-Compat-0.12
Running Makefile.PL
Can't locate inc/Module/Install.pm in #INC (you may need to install the inc::Module::Install module) (#INC contains: /home/feelsafe/web/local/lib/perl5/x86_64-linux-gnu-thread-multi /home/feelsafe/web/local/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
-> N/A
-> FAIL Configure failed for MRO-Compat-0.12. See /home/feelsafe/.cpanm/work/1524673518.17946/build.log for details.
Currently I have found this article, but still do not understand the problem.
What did I miss on my system? And what is the problem?
Because I use Carton to deploy my application:
carton install --deployment
I have List-MoreUtils-0.416 in my cpanfile.snapshot. Thus I use old module version which relies on "." exists at #INC.
But on target host, where I was faced into Can't locate inc/latest.pm in #INC problem there is DEBIAN perl-5.24.1 which apply patch from perl-5.26 which removes '.' from #INC
Because of this inc::latest is not found in bundled directory
To resolve my issue I just add next line into cpanfile:
requires 'List::MoreUtils', '>=0.428'
Unfortunately carton update do not update all modules from cpanfile.snapshot just only mentioned at cpanfile.
Also, I think, it will be OK to install inc::latest
You may be using the "system" perl (cf. perlbrew) where the library paths in %INC assume modules are installed using the operating system's package manager.
When building modules it's sometimes easier to use a locally built perl, a module "bootstrapping" utility like local::lib, or perlbrew to manage your "non-system" instance of perl. This allows you to easily avoid mixing module packages installed by the OS with your own locally built modules.

SNMPTT and perl snmp module troubleshooting

I'm on centos6.7 and i need to install snmptt to get all SNMP traps and log them into Nagios. I made it work yesterday, but today, not the same story...
I've run the yum install perl-Net-SNMP command, it told me that the package is already installed (from epel)
I've enabled the module on the snmptt.ini and now, when i'm trying to run it, I've a failed message :
root#SLINUX01:[~]$service snmptt restart
Stopping snmptt: [FAILED]
Starting snmptt: Can't locate SNMP.pm in #INC (#INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at (eval 12) line 1.
Could not load the Perl module SNMP! If net_snmp_perl_enable is
enabled then the SNMP module is required. Please see snmptt.html
for system requirements. Note: SNMPTT uses the Net-SNMP package's
SNMP module, NOT the CPAN Net::SNMP module!
died at /usr/sbin/snmptt line 426.
Suggestions ?
Found the solution : just install a different package :
yum install net-snmp-perl =/= yum install perl-Net-SNMP
The provided solution also worked for SNMPTT on Oracle Linux 7.5.
yum install net-snmp-perl
worked for me.

Trying to install Net::OpenSSH but getting back invalid version for dependencies

I'm working with some perl 5.8.8 legacy code and I usually check my installed packages with perl -MNet::OpenSSH -e 'print "worked \n"'
If it's absent it states:
Can't locate Net/OpenSSH.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .).
BEGIN failed--compilation aborted.
Which is normal. Then I run cpanm and it installs. However, with this OpenSSH module I am getting back that some dependencies are not a valid version.
kristen:/web# cpanm Net::OpenSSH
install is up to date. (0.01)
--> Working on Net::OpenSSH
Fetching http://www.cpan.org/authors/id/S/SA/SALVA/Net-OpenSSH-0.62.tar.gz ... OK
Configuring Net-OpenSSH-0.62 ... OK
Failed to clean-up 2 metadata. Errors:
'version=HASH(0x8eb66f4)' for 'Test::More' is not a valid version. (prereqs -> runtime -> requires -> Test::More) [Validation: 2]
'version=HASH(0x8eb6700)' for 'ExtUtils::MakeMaker' is not a valid version. (prereqs -> configure -> requires -> ExtUtils::MakeMaker) [Validation: 2]
'version=HASH(0x8eb69f4)' for 'ExtUtils::MakeMaker' is not a valid version. (prereqs -> build -> requires -> ExtUtils::MakeMaker) [Validation: 2]
I used cpanm upgrade Test::More which didn't resolved the problem for that module so I think I need a lower version number. So how do I check what versions I need to use Net::OpenSSH?
Upgrading cpanm and then installing the module resolved the issue.

Unable to install HTML::TreeBuilder::XPath with cpanm

I'm trying to install HTML::TreeBuilder::XPath as user. but I get this error :
Building and testing HTML-Parser-3.71 ... FAIL
! Installing HTML::Entities failed. See /home/user/.cpanm/build.log for details.
So if I take a look at this file /home/user/.cpanm/build.log I get this error :
Result: FAIL
Failed 3/48 test programs. 0/423 subtests failed.
make: *** [test_dynamic] Error 255
-> FAIL Installing HTML::Entities failed. See /home/user/.cpanm/build.log for details.
Searching HTML::Parser on cpanmetadb ...
Already tried HTML-Parser-3.71. Skipping.
Already tried HTML::Tagset. Skipping.
-> FAIL Bailing out the installation for HTML-Tree-5.03. Retry with --prompt or --force.
-> FAIL Bailing out the installation for HTML-TreeBuilder-XPath-0.14. Retry with --prompt or --force.
3 distributions installed
So I try to manualy install HTML::Entities and I get this error :
Successfully installed HTML-Tagset-3.20
Building and testing HTML-Parser-3.71 ... FAIL
! Installing HTML::Entities failed. See /home/user/.cpanm/build.log for details.
1 distribution installed
Can't locate HTML/Tagset.pm in #INC (#INC contains: /home/user/.cpanm/work/1403630727.28688/HTML-Parser-3.71/blib/lib /home/user/.cpanm/work/1403630727.28688/HTML-Parser-3.71/blib/arch /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /home/user/.cpanm/work/1403630727.28688/HTML-Parser-3.71/blib/lib/HTML/TokeParser.pm line 10.
So it say it can't locate HTML::Tagset, but it has been installed just a few line before ! And at the end, I get this errors :
Result: FAIL
Failed 3/48 test programs. 0/423 subtests failed.
make: *** [test_dynamic] Error 255
-> FAIL Installing HTML::Entities failed. See /home/user/.cpanm/build.log for details.
1 distribution installed
and if I take a look at /home/user/.cpanm/build.log I get exactly the same output.
What's wrong please ?
Given that you cannot find the HTML::Tagset module from the command line, it is possible you did not actually install it, despite being told that you had.
One other test for it wold be:
$ perldoc HTML::Tagset
Then I would look for it using locate(1)
$ locate HTML/Tagset.pm
You may get a lot of output that you'll have to go through, or you might get none. You might be told that the database that locate relies on is not initialized, or is out of date. You can either refresh the database, or try find(1)
$ find / -name 'Tagset.pm' -print | less
If you still cant find it, or you grow tired of searching, then just fire up your favorite CPAN client, and install HTML::Tagset and then HTML::Entities explicitly.
I havent told cpanminus to use my local library.
Here is the solution to install all module as user :
cd ~/;
cpanm local::lib;
echo 'eval `perl -I$HOME/perl5/lib/perl5 -Mlocal::lib`' >> ~/.bashrc ;
source ~/.bashrc;
after that, I can install all modules and dependancies as user with
cpanm module::name