Unable to load (and reinstall) Socket.pm after upgrade - perl

I've just upgraded Slackware64 to 14.1 and I found Perl 5.18 in it. Socket.pm now complains that it was compiled for another Perl version, which was 5.16. Here is the error:
Perl API version v5.16.0 of Socket does not match v5.18.0 at /usr/share/perl5/XSLoader.pm line 92.
Unfortunately, I'm even unable to reinstall Socket.pm even with cpan.
$ cpan Socket
Reading '/home/francesco-salix/.cpan/Metadata'
Database was generated on Tue, 26 Nov 2013 09:08:12 GMT
Running install for module 'Socket'
Running make for P/PE/PEVANS/Socket-2.013.tar.gz
Checksum for /home/francesco-salix/.cpan/sources/authors/id/P/PE/PEVANS/Socket-2.013.tar.gz ok
CPAN.pm: Building P/PE/PEVANS/Socket-2.013.tar.gz
Attempt to reload Socket.pm aborted.
Compilation failed in require at /usr/share/perl5/IPC/Cmd.pm line 46.
BEGIN failed--compilation aborted at /usr/share/perl5/IPC/Cmd.pm line 46.
Compilation failed in require at /usr/share/perl5/ExtUtils/CBuilder/Base.pm line 11.
BEGIN failed--compilation aborted at /usr/share/perl5/ExtUtils/CBuilder/Base.pm line 11.
Compilation failed in require at /usr/share/perl5/ExtUtils/CBuilder/Platform/Unix.pm line 4.
BEGIN failed--compilation aborted at /usr/share/perl5/ExtUtils/CBuilder/Platform/Unix.pm line 4.
Compilation failed in require at (eval 6) line 2.
BEGIN failed--compilation aborted at (eval 6) line 2.
Compilation failed in require at Makefile.PL line 19.
Warning: No success on command[/usr/bin/perl5.18.1 Makefile.PL]
'YAML' not installed, will not store persistent state
PEVANS/Socket-2.013.tar.gz
/usr/bin/perl5.18.1 Makefile.PL -- NOT OK
Running make test
Make had some problems, won't test
Running make install
Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites
As far as I've understood, Socket.pm is a Perl core module. So, I thought it would have been upgraded together with Perl.
Here are directories currently in #INC:
$ perl -E'say for #INC'
/home/francesco-salix/perl5/lib/perl5/x86_64-linux-thread-multi
/home/francesco-salix/perl5/lib/perl5
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.
I see some folders seems duplicate, but I don't actually know if they are supposed to be like that. However, there's no Socket.pm in the first two path (which I assume where added by cpan while running under my user, while I've a Socket.pm file for both /usr/local/lib64/perl5/ and /usr/lib64/perl5.

Socket.pm is indeed a core module. And the CPAN.pm moduleExtUtils::MakeMaker uses it (via IPC::Cmd), so if Socket.pm is broken, CPAN.pmMakefile.PL will be broken too.
Given that it is a core module, and would have been installed with Perl, this suggests to me that Perl is trying to load Socket.pm from some other, older path. The following will tell you where Perl is trying to load modules from:
perl -E'say for #INC'
Is there anything suspicious in there. Any place it might find older modules compiled for Perl 5.16?

The solution is to clear the old modules, following 3rensho’s comment:
sudo rm -rf /usr/local/lib64/perl5/*
sudo rm -rf /usr/local/share/perl5/*
It works!

Related

Issue while installing DBI Perl module in Solaris 11

I am trying to install Perl DBI module on Solaris 11 manually using Make install:
You can verify the steps mentioned below.
/usr/perl5/5.12/ModulesTars/DBI-1.643# make test
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty'
-- DBI.bs blib/arch/auto/DBI/DBI.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-Iblib/lib" "-Iblib/arch" test.pl
test.pl
DBI test application $Revision$
Can't load '/usr/perl5/5.12/ModulesTars/DBI-1.643/blib/arch/auto/DBI/DBI.so'
for module DBI: ld.so.1: perl:
fatal: /usr/perl5/5.12/ModulesTars/DBI-1.643/blib/arch/auto/DBI/DBI.so:
wrong ELF class: ELFCLASS64 at
/usr/perl5/5.12/lib/sun4-solaris-64int/DynaLoader.pm line 200.
at /usr/perl5/5.12/ModulesTars/DBI-1.643/blib/lib/DBI.pm line 284
BEGIN failed--compilation aborted at
/usr/perl5/5.12/ModulesTars/DBI-1.643/blib/lib/DBI.pm line 284.
Compilation failed in require at test.pl line 23.
BEGIN failed--compilation aborted at test.pl line 23.
*** Error code 2
make: Fatal error: Command failed for target `test_dynamic'
/usr/perl5/5.12/ModulesTars/DBI-1.643#
Getting above error while running make test command. Please help to find the resolution.
Per Oracle's Solaris 11 Perl 5 documentation:
Perl 5 includes a dynamically loadable module framework, which allows the addition of new capabilities for specific tasks. Many modules are freely available from the Comprehensive Perl Archive Network (CPAN) at http://www.cpan.org. If you wish to build and install add-on modules from CPAN using gcc, you can do so using the /usr/perl5/5.8.4/bin/perlgcc or the /usr/perl5/5.12/bin/perlgcc script. See the perlgcc(1) man page with the 5.8.4 distribution for details.
Offtopic:
Given your comment
This is perl 5, version 12, subversion 5 (v5.12.5) built for sun4-solaris-64int (with 7 registered patches, see perl -V for more detail)
Are you really installing user-compiled modules as root into the system's Perl installation? Since you have "7 registered patches", it seems that this is a system under an Oracle support contract. Installing user-compiled modules as root into the system Perl installation risks your system's stability and likely violates your support contract.

Perl CPAN Can't locate CPAN/Author.pm... when trying to install nipe

I'm trying to install "nipe" on my Windows Machine but i get this error code all the time. I have installed Strawberry Perl.
This is the error code:
Can't locate CPAN/Author.pm in #INC (you may need to install the CPAN::Author module) (#INC contains: /usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl) at /usr/share/perl5/core_perl/CPAN.pm line 19.
BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/CPAN.pm line 19.
Compilation failed in require at /usr/share/perl5/core_perl/App/Cpan.pm line 290.
BEGIN failed--compilation aborted at /usr/share/perl5/core_perl/App/Cpan.pm line 290.
Compilation failed in require at /c/Strawberry/perl/bin/cpan line 7.
BEGIN failed--compilation aborted at /c/Strawberry/perl/bin/cpan line 7.
While you may have Strawberry Perl installed, that's not the perl you are using. C:\Strawberry\perl\bin\cpan uses the first perl in your PATH, which isn't your installation of Strawberry Perl. It appears that you are using some unix emulation (Cygwin? MSYS?) and using the perl from that emulation.
To use your Strawberry Perl build of perl, you could adjust your PATH so that SP comes before whatever perl you ended up using, or you could use
C:\Strawberry\perl\bin\perl C:\Strawberry\perl\bin\cpan Try::Tiny Config::Simple JSON
or
C:\Strawberry\perl\bin\perl -MCPAN -e"install #ARGV" Try::Tiny Config::Simple JSON
in lieu of
cpan Try::Tiny Config::Simple JSON
Similarly, if you don't adjust your path, you'll need to use
C:\Strawberry\perl\bin\perl nipe.pl ...
in lieu of
perl nipe.pl ...
If your are using windows and a bash then try to it with cmd or powershell after you applied the changes from #ikegami. Took me some time to figure out, that it had no effect to change the paths for this terminal, as it still took the paths from /usr//perl5/
I tried to do all of the other answers, but it didn't work. Instead it appeared that it doesn't work because I tried to run it from unix shell script (sh in powershell or git bash). After moving it from .sh to .ps1 and running non-unix way it works perfectly.

Can't locate Text/Soundex.pm in #INC

I was installing repeatsmasker and it apparently seems to work because it shows "Congratulations! RepeatMasker is now ready to use."
But when I run it it reports "Can't locate Text/Soundex.pm...". so I installed the module by "sudo cpan Text::Soundex", and by the end it tells me "Text::Soundex is up to date (3.05)." It seems the module is already installed, but RepeatMasker still has the same problem, as I'll show you in this code:
fragua#picci:~/RM/RepeatMasker$ sudo cpan Text::Soundex
Loading internal null logger. Install Log::Log4perl for logging messages
Reading '/home/fragua/.cpan/Metadata'
Database was generated on Fri, 19 Apr 2019 22:17:03 GMT
Text::Soundex is up to date (3.05).
fragua#picci:~/RM/RepeatMasker$ ./RepeatMasker -s -lib /home/fragua/RepeatScout-1.0.5/ObiINK5k_repeats_filtered1.fasta /home/fragua/Documenti/Workdirectory/ObiINC5k.fa
Can't locate Text/Soundex.pm in #INC (you may need to install the Text::Soundex module) (#INC contains: /home/fragua/RM/RepeatMasker /home/fragua/perl5/lib/perl5 /home/fragua/anaconda/lib/site_perl/5.26.2/x86_64-linux-thread-multi /home/fragua/anaconda/lib/site_perl/5.26.2 /home/fragua/anaconda/lib/5.26.2/x86_64-linux-thread-multi /home/fragua/anaconda/lib/5.26.2 .) at /home/fragua/RM/RepeatMasker/Taxonomy.pm line 80.
BEGIN failed--compilation aborted at /home/fragua/RM/RepeatMasker/Taxonomy.pm line 80.
Compilation failed in require at ./RepeatMasker line 310.
BEGIN failed--compilation aborted at ./RepeatMasker line 310.
I installed RepeatMasker in another computer without problems, but I don't know why now I encontered this problem
You have two builds of Perl installed:
/usr/bin/perl
/home/fragua/anaconda/bin/perl.
/home/fragua/anaconda/bin/perl is first in your PATH. This means that programs with the following shebang (#!) line will use /home/fragua/anaconda/bin/perl:
#!/usr/bin/env perl
RepeatMasker appears to be such a program.
All of this is fine.
The Problem
/home/fragua/anaconda/bin contains the scripts installed by /home/fragua/anaconda/bin/perl. As part of the installation process of these scripts, the shebang line of these scripts should have been rewritten to specify /home/fragua/anaconda/bin/perl.
However, the shebang line of /home/fragua/anaconda/bin/cpan references /usr/bin/perl. This means that using /home/fragua/anaconda/bin/cpan would install modules for /usr/bin/perl, not /home/fragua/anaconda/bin/perl.
The Workaround
You could avoid relying on the shebang line and explicitly specify the correct perl.
/home/fragua/anaconda/bin/perl /home/fragua/anaconda/bin/cpan Text::Soundex
Or, given your $PATH,
perl /home/fragua/anaconda/bin/cpan Text::Soundex
The Fix
To fix this problem in an ongoing manner requires changing the shebang lines of the scripts to be what they should be. In every file in /home/fragua/anaconda/bin (and in particular for cpan), replace
#!/usr/bin/perl
with
#!/home/fragua/anaconda/bin/perl
You could do this use the following (which does a backup of the files it changes):
perl -0777ne'print "$ARGV\n" if m{^#!\s*/usr/bin/perl\b}' /home/fragua/anaconda/bin/* \
| xargs perl -i~ -0777pe's{^#!\s*/usr/bin/perl\b}{#!/home/fragua/anaconda/bin/perl}'

cpan command gives the error "Can't locate B.pm in #INC"

I wanted to use CPAN to install some Perl packages, but I get the following error when I try to start the CPAN shell:
paulzierep#naproxen:~$ cpan
Can't locate B.pm in #INC (you may need to install the B module) (#INC contains: /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/paulzierep) at /usr/share/perl/5.22/Safe.pm line 34.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/Safe.pm line 34.
Compilation failed in require at /usr/share/perl/5.22/CPAN.pm line 56.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/CPAN.pm line 56.
Compilation failed in require at /usr/share/perl/5.22/App/Cpan.pm line 273.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/App/Cpan.pm line 273.
Compilation failed in require at /usr/bin/cpan line 9.
BEGIN failed--compilation aborted at /usr/bin/cpan line 9.
I can't figure out how to install the missing B module without cpan. I guess this should be installed by default.
I'm using Perl 5.22.1 on Ubuntu 16.04.
Update
So I set the PERL5LIB or PERL5OPT to make it find /usr/lib/x86_64-linux-gnu/perl/5.22.1/B.pm, and CPAN runs, but I can not install anything due to 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
So it kind of fixed it and left me with another problem. Any help on this one?
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
I had the same problem. For some unknown reason, the directory /usr/lib/x86_64-linux-gnu/perl was empty. My solution was to reinstall the libperl5.22 package.
sudo apt-get install --reinstall libperl5.22
So after having a look on a different systems with pretty similar set-up I found whats the problem with my perl install. It always bugged me, that the 5.22 folder is empty, but still seems to be the folder perl is looking for.
paulzierep#naproxen:/usr/lib/x86_64-linux-gnu/perl$ ls
5.22 5.22.1 cross-config-5.22.1 debian-config-data-5.22.1
In a system with similar set-up I found that the 5.22 was linking to 5.22.1, setting this link solved the problem and perl runs again like a charm.
I additional wanted to point out, that in my reseach I found that the working directory "." seems to be in #INC by default, (http://www.perlmonks.org/bare/?node_id=375341) therefore I am wondering why it seems so strange to some (#Borodin), that my home directory is there (Any directory is there as long as you start cpan from there).
Also I don't see how perlbrew would help here, besides the fact, that you cannot install it without working perl, I don't see how it would help, when your system perl does not work properly.
$ cpan
Can't locate File/Spec.pm: /usr/local/lib/x86_64-linux-gnu/perl/5.22.1/File/Spec.pm: Permission denied at /usr/share/perl/5.22/CPAN.pm line 10.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/CPAN.pm line 10.
Compilation failed in require at /usr/share/perl/5.22/App/Cpan.pm line 273.
BEGIN failed--compilation aborted at /usr/share/perl/5.22/App/Cpan.pm line 273.
Compilation failed in require at /usr/bin/cpan line 9.
BEGIN failed--compilation aborted at /usr/bin/cpan line 9.
Perl don't looking modules in #INC.

twiki "Failed to load the perl module FindBin."

I am trying to get TWIKI to work (virtual Server Hosteurope .. PLESK 11 CentOS 6).
When I run the configure script the following error appears:
[root#lvpsx.x.x.x bin]# ./configure
Failed to load the perl module FindBin. The module was found at /usr/share/perl5/FindBin.pm
Please ensure that:
1 FindBin is installed,
2 that the module is available on the #INC path,
3 that the webserver user (root) has permission to read the FindBin.pm file.
The detailed error seen was:
Subroutine export_fail redefined at /usr/share/perl5/Carp.pm line 25.
Compilation failed in require at /usr/share/perl5/FindBin.pm line 95.
BEGIN failed--compilation aborted at /usr/share/perl5/FindBin.pm line 95.
Compilation failed in require at (eval 3) line 2.
BEGIN failed--compilation aborted at (eval 3) line 2.
I have only marginal knowledge about the usage of shells and much less experience with Perl.
I run the configure script as root. As Far as I know Apache runs as root too(PLESK 11).
FindBin.pm is located in the named dir and I already tried to set it to 777.
Try installing VMS::Filespec, which seems to be the module FindBin is trying to require.
On the shell:
cpanm VMS::Filespec
If that doesn't work (the command fails), then try first:
cpan App::cpanminus
...and then try the first command again.
HTH
Francisco