CPAN on Ubuntu Can't locate local/lib.pm - perl

I just set up an Ubuntu 16.04 box and am trying to get some Perl modules installed. I launched CPAN, and it went through the automatic config procedure. At the end it dumped a few questionable messages:
Couldn't untar local-lib-2.000019.tar: 'Cannot allocate memory'
'YAML' not installed, will not store persistent state
HAARG/local-lib-2.000019.tar.gz
Had problems unarchiving. Please build manually
Can't locate local/lib.pm in #INC (you may need to install the local::lib module) (#INC contains: /home/steve/perl5/lib/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base /home/steve/waternow) at /usr/share/perl/5.22/CPAN/FirstTime.pm line 1347.
When I restarted it, it came up with the CPAN shell command line like nothing is wrong. Did it get configured correctly, or is there something else I need to do? I'm not a Lunix noob but not an expert either.
Also are there any better options for installing Perl modules on Ubuntu besides CPAN (for example like Activestate Perl Package Manager on Windows)? I've never been too fond of CPAN because of experiences like this.

Related

Perl mixed up, Cpan can not install

Hi I wanted to install a package via cpan, but I get the following error:
cpan[1]> install Log::Log4perl
Reading '/home/paulzierep/.cpan/Metadata'
Database was generated on Fri, 30 Sep 2016 06:29:02 GMT
Running install for module 'Log::Log4perl'
Checksum for /home/paulzierep/.cpan/sources/authors/id/M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz ok
Scanning cache /home/paulzierep/.cpan/build for sizes
............................................................................DONE
'YAML' not installed, will not store persistent state
Configuring M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Have /usr/lib/x86_64-linux-gnu/perl/5.22.1
Want /usr/lib/x86_64-linux-gnu/perl/5.22
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [5.22.1]
Config says: [x86_64-linux-gnu-thread-multi]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Generating a Unix-style Makefile
Writing Makefile for Log::Log4perl
Writing MYMETA.yml and MYMETA.json
MSCHILLI/Log-Log4perl-1.47.tar.gz
/usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for M/MS/MSCHILLI/Log-Log4perl-1.47.tar.gz
make: *** No rule to make target '/usr/lib/x86_64-linux-gnu/perl/5.22/Config.pm', needed by 'Makefile'. Stop.
MSCHILLI/Log-Log4perl-1.47.tar.gz
/usr/bin/make -- NOT OK
Failed during this command:
MSCHILLI/Log-Log4perl-1.47.tar.gz : make NO
Well it says to check my perl installation, which is:
perl --version
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi
(with 58 registered patches, see perl -V for more detail)
Copyright 1987-2015, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Here's #INC:
/usr/lib/x86_64-linux-gnu/perl/5.22.1/ /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base
That what I get for:
paulzierep#naproxen:~$ perl -E 'say for #INC'
/etc/perl
/usr/local/lib/x86_64-linux-gnu/perl/5.22.1
/usr/local/share/perl/5.22.1
/usr/lib/x86_64-linux-gnu/perl5/5.22
/usr/share/perl5
/usr/lib/x86_64-linux-gnu/perl/5.22
/usr/share/perl/5.22
/usr/local/lib/site_perl
/usr/lib/x86_64-linux-gnu/perl-base
.
paulzierep#naproxen:/home$ perl -MFile::Spec -E 'say for File::Spec->path'
/home/paulzierep/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin
This typically happens when the perl you invoke looks in library directories that other perls left behind. Part of the error is:
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Start investigating there. Find out where it's finding the mismatched Config.pm and fix that issue. Running perl -V to see what's in #INC will help.
Beyond that you'll have to tell us a lot more about your setup.
You've previously mentioned adding a directory to PERL5LIB you shouldn't have added. Please reverse this change and this problem will go away.
You should really take another look at the comments on your previous question
Why does the default cpan on Ubuntu 16.04 give the error "Can't locate B.pm in #INC"?
where I observed that your #INCcontains your home directory /home/paulzierep in the last position
I asked whether the environment variables PERL5LIB or PERL5OPT were set, and your only response says
I changed the PERL5LIB environement var to usr/lib/x86_64-linux-gnu/perl/5.22.1/ and indeed I am able to open the cpan shell, but ones I try an install now, I get: Your perl and your Config.pm seem to have different ideas about the architecture they are running on
I don't know what you have done to get your home directory at the end of #INC. Both PERL5LIB and the -I command-line options use unshift instead of push, and add locations to the start of the #INC array
It's quite possible to build a new perl image with your home directory in #INC by default, but surely you would have said so if that is what you had done?
Let me be clear: PERL5LIB and PERL5OPT should be undefined for normal operation of perl
So after deleting the perl related environment variables I came back to my previous error post cpan command gives the error "Can't locate B.pm in #INC".
Which I managed to solve, so I assume this answers this post then as well.

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.

Cannot locate a perl module

I am trying to run a topology generation tool (http://informatique.umons.ac.be/networks/igen/) on linux where I need to install plenty of modules of perl.
For now, I have already installed CPAN. This tool requires a Statistics::Basic module which I also installed successfully.
However, after installing this module, the tool requires a package in this Statistics::Basic module. Here are the hints appeared in the command line:
Can't locate Statistics/Basic/CoVariance.pm in #INC (you may need to install the Statistics::Basic::CoVariance module) (#INC contains: /usr/local/share/perl/5.18.2/ /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 .)
I get confused on this request since it is already included in the Statistics::Basic module. Even though I tried to install it independently, the cpan responded this:
cpan[1]> install Statistics::Basic::CoVariance
Warning: Cannot install Statistics::Basic::CoVariance, don't know what it is.
Does anyone know how to fix it? I am new to perl so I don't know how to make it work. Thx.
You need to replace the capital V with a small v in a couple of files and you need also some other modifications. You can find here a guide on how to make IGen-0.15 work again.

Can't locate local/lib.pm in #INC at /usr/share/perl/5.14/CPAN/FirstTime.pm

I am trying to use Perl the first time on my system which is Ubuntu 12.04. I have Perl v.5.14.2 installed.
I looked up how to install Perl modules, so I started as follows:
$ perl -MCPAN -e shell
The wizard started configuring the environment as can be seen here: http://pastebin.com/5hn8vkb5
Though, it stopped in the middle with the following error message:
...
Checksum for /home/john/.cpan/sources/authors/id/A/AP/APEIRON/local-lib-1.008009.tar.gz ok
---- Unsatisfied dependencies detected during ----
---- APEIRON/local-lib-1.008009.tar.gz ----
ExtUtils::MakeMaker [build_requires]
Running make test
Make had some problems, won't test
Delayed until after prerequisites
Running make install
Make had some problems, won't install
Delayed until after prerequisites
Can't locate local/lib.pm in #INC (#INC contains:
/home/john/perl5/lib/perl5
/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
/home/john/Desktop)
at /usr/share/perl/5.14/CPAN/FirstTime.pm line 1300.
What can I do to setup the Perl environment correctly on my Ubuntu installation?
After interrupting the wizard and restarting it again, there is no error message anymore.
How can I start the wizard again so I can choose here:
What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')
[local::lib]
You're missing local::lib, which is what you told CPAN shell to do.
You can install it like so:
sudo apt-get install liblocal-lib-perl
You might be able to start over by rm -rf-ing your ~/.cpan directory. AT YOUR OWN RISK
However, I would recommend trying cpanminus instead of the old CPAN shell.
sudo apt-get install cpanminus
The local namespace was for your own personal modules and wouldn't be found in CPAN. This is something relatively new. At many sites, you might need CPAN modules not in the current version of Perl, or you need a newer version of a particular module. However, you don't have write access to the standard location where CPAN modules are installed.
What this is doing is installing these modules under the $HOME/perl5/lib/local directory where you'll be able to access them. You would also need to setup a PERL5LIB environment variable (usually in your startup scripts), so Perl will check this directory when locating these modules.
If you have sudo privileges, use that to install CPAN modules rather than trying this. The following will install the Foo::Bar module into the standard module directory for you (and do any configuration as necessary):
$ sudo cpan install Foo::Bar
If CPAN needs to be configured, it will do that first.
There are complete directions on doing the local::lib install for modules on MetaCPAN. They're pretty clear.
Several New OS's force (like Redhat 7) force to check presence of local::lib in the perl version, actually its a good thing this enables to users to use CPAN and add,experiment and enjoy new modules to be used with the perl without waiting for sitewide installation (like a root user). By default local::lib looks for $HOME/perl5 dir where the user's local or downloaded modules are located. If you see this problem then you have to do following
sudo su - whatever_user_owns_perl
whatever_perl_install_path/cpan install local::lib

Icinga - Nagios - check_esx3.pl fails while executing

I'm trying to add an check_esx3.pl script to my icinga. But trying to execute the script
./check_esx3.pl
Gives me the following error:
Can't locate Nagios/Plugin.pm in #INC (#INC contains: /etc/perl
/usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
/usr/local/lib/site_perl .) at ./check_esx3.pl line 31. BEGIN
failed--compilation aborted at ./check_esx3.pl line 31.
I've been looking around and googling, but I've not been able to find any solution.
You need to install the Nagios::Plugin Perl module.
When you build the Nagios Plugins package from https://www.nagios-plugins.org, one of the configure options is --enable-perl-modules. It will build the Nagios::Plugin:* modules (since it has several modules included that need them), and install them to your system Perl library directory when you run 'make install' as root.
You can also go directly to the source and install the modules from CPAN, by running the command cpan Nagios::Plugins from the command line, also as root. You could possibly run these as the icinga or nagios user, but there's no guarantee they'll get installed into the proper places unless you've done some work beforehand to define PERL5LIB (which is way out of the scope of this answer) and done a bit of hackery in your startup scripts that define a special PERL5LIB for the icinga/nagios process on startup.