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

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}'

Related

utf8::all on perl-5.12.3 doesn't work and I can't uninstall it

On Mac OS X 10.7.5 on which perl-5.12.3 is installed, I needed to use the utf8::all module so I have manually installed utf8-all-0.024 (Note the minimum perl version of v5.10.0 on its CPAN page) The make test has failed but I've still installed it to see if it would work. It didn't work so I've decided to uninstall it. I've tried 2 methods given at perl.com the first method didn't work as it required perl-5.14.2 The second method gave this message:
! utf-8 is not found in the following directories and can't be uninstalled.
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
and it couldn't uninstall it either. How to uninstall the utf8-all-0.024?
Furthermore, I had a small script listing all the Perl modules. It is:
use ExtUtils::Installed;
my $inst = ExtUtils::Installed->new();
my #modules = $inst->modules();
foreach $module (#modules) {
print $module . "\n";
}
This script started to take about a minute and half of the CPU time, to list the modules. Before I messed up the system, it was giving instant result. How to rectify it?
For the sake of completeness here is the #INC as given by the perl -V
#INC:
/Library/Perl/5.12/darwin-thread-multi-2level
/Library/Perl/5.12
/Network/Library/Perl/5.12/darwin-thread-multi-2level
/Network/Library/Perl/5.12
/Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3
/System/Library/Perl/5.12/darwin-thread-multi-2level
/System/Library/Perl/5.12
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.12
.
Further info:
perl -Mutf8::all -e 'print $INC{"utf8/all.pm"}, "\n"' gives:
Can't locate Import/Into.pm in #INC (#INC contains: /Library
/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12 /Network
/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library
/Perl/5.12 /Library/Perl/Updates/5.12.3/darwin-thread-multi-2level
/Library/Perl/Updates/5.12.3 /System/Library/Perl/5.12/darwin-
thread-multi-2level /System/Library/Perl/5.12 /System/Library
/Perl/Extras/5.12/darwin-thread-multi-2level /System/Library
/Perl/Extras/5.12 .) at /Library/Perl/5.12/utf8/all.pm line 140.
BEGIN failed--compilation aborted at /Library/Perl/5.12/utf8/all.pm line 140.
Compilation failed in require.
BEGIN failed--compilation aborted.
You've made a mess of things by incorrectly installing the module. Specifically, you didn't install the dependencies.
Ideally, you should use the package manager that provided perl itself. But they don't provide every module. So you'd use the non-package manager approach:
cpan utf8::all
(I prefer to install my own perl using perlbrew, then I can use cpan without worry.)
Now, cpan might claim that utf8::all is already installed. If so, this should get you straightened out:
cpan -t utf8::all
cpan -f utf8::all # Only if the previous command says everything is ok!

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 XML/XPath.pm in #INC

I have a .pl script in which starts by:
#!/usr/bin/perl
use XML::XPath;
use Getopt::Long;
I can't seem to run that via perl myScript.pl, having this error:
(#INC contains: /usr/share/ /usr/local/lib64/perl5 /usr/local/share/perl5/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at most_generic_wrapper.pl line 3.
BEGIN failed--compilation aborted at myScript.pl line 3.
1- I tried to locate the XPath.pm file and export that as:
export PERL5LIB=/usr/share/perl5/XML/Twig
and
export PERL5LIB=/usr/share/perl5/XML
2- Installed perl -MCPAN -e 'install XML::Parser'
3- Used -I to explicitly define the path as:
perl -I perl -MCPAN -e 'install XML::Parser' myScript.pl
4- changing the line 3 to use XML::Twig::XPath; led to:
cannot use XML::Twig::XPath: neither XML::XPathEngine 0.09+ nor XML::XPath are available at /usr/share/perl5/XML/Twig/XPath.pm line 11.
BEGIN failed--compilation aborted at /usr/share/perl5/XML/Twig/XPath.pm line 13.`
But none of them solved the issue and I keep receiving the same error at line.3.
P.S: Running on CentOS 6.2 with the kernel 2.6.32-358 and perl --version=v5.10.1 (*) built for x86_64-linux-thread-multi
Any helps would be appreciated,
Your title says XML::XPath can't be found, but your question indicates you tried to install XML::Parser. Did you try to install XML::XPath?
From man perlrun: "If PERL5LIB is not defined, PERLLIB". You seem to have tried setting PERLIB5 (notice the spelling difference: the var is PERL5LIB (or PERLLIB), not PERLIB5).
From man perlrun: "PERL5LIB -- A list of directories in which to look for Perl library files before looking in the standard library and the current directory." You seem to have tried setting it to the full path to a .pm file, rather than a directory.
The file you assigned would be XML::Twig::XPath, not XML::XPath; those are two different Perl modules.
Edit: After looking at your revised question:
I'm not sure if your script requires XML::Twig::XPath or XML::XPath, or if either one can provide the API you need. However, XML::Twig::XPath seems to depend on XML::XPath so you will need XML::XPath no matter what, and it looks like XML::XPath is not installed on your system. I think that's probably the main problem. Please try to install XML::XPath using CPAN.
The value of the PERL5LIB variable (or the argument to the -I option) should be the directory that sits at the base of the package-qualified module file. For example, if XML::XPath is located at ~/perl_custom_modules/XML/XPath.pm, then you need to set PERL5LIB (or the -I argument) to ~/perl_custom_modules. The XML directory is part of the package qualification of the module, so does not need to be included in the include path.

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

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!

Add path to Global PERL #INC, System-wide, not in my scripts, but Globally. On a Mac

I'm having the following problem I don't know what introduced it but perl include path's on a Mac were always a nightmare;
cpan[1]> install DateTime::Event::Recurrence
Going to read '/Users/Hristo/.cpan/Metadata'
Database was generated on Tue, 08 Jan 2013 11:07:23 GMT
Fetching with LWP:
http://ftp.belnet.be/mirror/ftp.cpan.org/authors/01mailrc.txt.gz
Catching error: "Can't locate HTML/HeadParser.pm in \#INC (\#INC contains: /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.12.4 /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.4 /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl /Users/Hristo) at /opt/local/lib/perl5/site_perl/5.12.4/LWP/UserAgent.pm line 663, <FIN> line 1. at /opt/local/lib/perl5/site_perl/5.12.4/LWP/UserAgent.pm line 915, <FIN> line 1.\cJ" at /opt/local/lib/perl5/5.12.4/CPAN.pm line 391, <FIN> line 1.
CPAN::shell() called at /opt/local/lib/perl5/5.12.4/App/Cpan.pm line 295
App::Cpan::_process_options('App::Cpan') called at /opt/local/lib/perl5/5.12.4/App/Cpan.pm line 364
App::Cpan::run('App::Cpan') called at /opt/local/bin/cpan line 11
Fetching with LWP:
http://ftp.belnet.be/mirror/ftp.cpan.org/authors/01mailrc.txt.gz
Terminal does not support GetHistory.
Lockfile removed.
Can't locate HTML/HeadParser.pm in #INC (#INC contains: /opt/local/lib/perl5/site_perl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.12.4 /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/vendor_perl/5.12.4 /opt/local/lib/perl5/5.12.4/darwin-thread-multi-2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl /Users/Hristo) at /opt/local/lib/perl5/site_perl/5.12.4/LWP/UserAgent.pm line 663, <FIN> line 1. at /opt/local/lib/perl5/site_perl/5.12.4/LWP/UserAgent.pm line 915, <FIN> line 1.
I have HTML::HeadParser in /opt/local/lib/perl5/site_perl/5.12.4/darwin-multi-2level/HTML
CPAN Has worked for months before this.
How do I change what's in #INC system wide so that both IDE (Eclipse) and CPAN know how to look.
I've been doing a global file search for Makefile.PL with commands such as sudo find / -name "*.PL" | xargs grep "Makefile" in various case to try find it and try this recommendation, with no success so far. (Oh how I hate this OS :))
I don't know the exact solution, may be this link will be helpful..
How is Perl's #INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)
If $Config{usesitecustomize} is defined, you can look for sitecustomize.pl at $Config{sitelib}\\sitecustomize.pl. See perlrun.
%Config variables tell you how perl has been compiled to run, so a re-compile would be necessary to change that.
Barring that, you could also alter any universal login scripts that are run--if any--so that the environment variable PERL5LIB contains your path--and I believe that the environment variable PERLLIB still works as well.