Perl modules not recognized - perl

I'm trying to run unitas_1.7.8.pl, a bioinformatic software available here. Importantly, I've used this software many times in the past successfully on this ubuntu machine. Now when I run the command
perl ~/scripts/unitas_1.7.0.pl -threads 24 -s homo_sapiens -i PCR_Primer_11_S11_L001_R1_001.trim.lng ...
I get the error
Perl module LWP::Simple is not installed on this machine!
Perl module Archive::Extract (in core since 2007-07-07) is not installed on this machine!
Perl modules are available for download at http://www.cpan.org/
If you have CPAN installed try the following:
cpan
install Archive::Extract
exit
If you are on MAC or UNIX you should run cpan with sudo:
sudo cpan
install Archive::Extract
exit
I've followed those instructions and updated AND reinstalled cpan (even though I know it should be fine) without apparent issues. The only thing I can think of that has changed since the last time I successfully used unitas is that the server was hard-rebooted a month ago.
Details:
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ cpan --version
Loading internal logger. Log::Log4perl recommended for better logging
/home/user/miniconda3/bin/cpan version 1.64 calling Getopt::Std::getopts (version 1.12 [paranoid]),
running under Perl version 5.30.3.
[Now continuing due to backward compatibility and excessive paranoia.
See 'perldoc Getopt::Std' about $Getopt::Std::STANDARD_HELP_VERSION.]
Nothing to install!
$ type -p perl; perl -M5.010 -e'say "$_: $ENV{$_}" for sort grep /^PERL/, keys(%ENV)'; echo 'o conf' | cpan
/home/stewart/miniconda3/bin/perl
[...]
make [/usr/bin/make]
make_arg []
make_install_arg []
make_install_make_command [/usr/bin/make]
makepl_arg [INSTALLDIRS=site]
mbuild_arg []
mbuild_install_arg []
mbuild_install_build_command [./Build]
mbuildpl_arg [--installdirs site]
[...]
$ perl -MLWP::Simple -E 'say $INC{"LWP/Simple.pm"}'
Can't locate LWP/Simple.pm in #INC (you may need to install the LWP::Simple module) (#INC contains: /home/stewart/miniconda3/lib/site_perl/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/site_perl/5.30.3 /home/stewart/miniconda3/lib/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/5.30.3 .).
BEGIN failed--compilation aborted.
$ head -n 1 "$( type -p cpan )"
#!/home/stewart/miniconda3/bin/perl
$ perl -MLWP::Simple -e'print "ok\n"'
Can't locate LWP/Simple.pm in #INC (you may need to install the LWP::Simple module) (#INC contains: /home/stewart/miniconda3/lib/site_perl/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/site_perl/5.30.3 /home/stewart/miniconda3/lib/5.30.3/x86_64-linux-thread-multi /home/stewart/miniconda3/lib/5.30.3 .).
BEGIN failed--compilation aborted.
current state of LWP::Simple and Archive::Extract
$ sudo cpan install LWP::Simple
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
Database was generated on Tue, 07 Sep 2021 08:55:47 GMT
LWP::Simple is up to date (6.56).
$ sudo cpan install Archive::Extract
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
Database was generated on Tue, 07 Sep 2021 08:55:47 GMT
Archive::Extract is up to date (0.88).
$ sudo cpan LWP::Simple
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/root/.cpan/Metadata'
Database was generated on Tue, 07 Sep 2021 08:55:47 GMT
LWP::Simple is up to date (6.56).

If you already have Miniconda, then you should install using the Bioconda channel in an isolated environment. Your Perl installation, from conda, is interfering with your system CPAN modules:
conda create -n unitas -c bioconda unitas
conda activate unitas
unitas.pl -threads 24 -s homo_sapiens -i PCR_Primer_11_S11_L001_R1_001.trim.lng ...
conda deactivate

None of the solutions suggested worked for me except calling perl directly from another directory (which already had it installed).
/usr/bin/perl5.30.0 ~/scripts/unitas_1.7.0.pl ...
There may be a way to switch the default perl used when called to this directory with $PATH, but I found this workaround for now. Thanks all for your help.

Related

cpan says App::cpanminus is up to date but cpanm doesn't come up in /usr/bin

SHORT QUESTION
I've installed cpanm on Mac mini G4 Leopard 10.5.8 with perl-8.8.8 using /usr/bin/cpan -i App::cpanminus and then **sudo** /usr/bin/cpan -i App::cpanminus It said App::cpanminus is up to date. but no cpanm is available in /usr/bin or anywhere else.
NOTE I've looked up the questionCan't locate module in #INC but CPAN says module is up to date and some others which seemed related to my case but they didn't help. Not much information is available in Google searches either.
LONG QUESTION
I've installed cpanm on Mac mini G4 Leopard 10.5.8 with perl-8.8.8 using /usr/bin/cpan -i App::cpanminus
All the downloading, extracting, compiling, etc went smoothly but at the last step, before installing it as (As Far As I Can Remember / AFAICR) /usr/bin/cpanm it stopped with a permission error (AFAICR) So I've repeated the same line with sudo:
~ $ sudo /usr/bin/cpan -i App::cpanminus
this time it said (again, AFAICR)
CPAN: Storable loaded ok
Going to read /Users/Mac/.cpan/Metadata
Database was generated on Thu, 09 Dec 2021 18:17:02 GMT
App::cpanminus is up to date.
and it didn't place the cpanm into /usr/bin or any other PATH directory.
Note that I need to use solely perl, v5.8.8 because it is the only version compatible with some of the system level Perl applications.
When I did a search on the ~/.cpanm and the default Mac OS X Perl installation folder which is /System/Library/Perl no instance of cpanm was found. So I gather cpanm is not created at all.
I've deleted the /Users/Mac/.cpan and repeated the sudo install and it ended up with the same message above (again, AFAICR)
So I got stuck in this. I didn't do anything else other than deleting ~/.cpan
How to install cpan on this Mac ?
Note 2 My question's title might not be best. Anyone is free to edit the title or the question.
Edit 1
I've tried the -f option but it said unknown option f
Here is how it goes:
~ $ sudo /usr/bin/cpan -if App::cpanminus
Unknown option: f
CPAN: Storable loaded ok
Going to read /Users/Mac/.cpan/Metadata
^C
~ $ sudo /usr/bin/cpan -f App::cpanminus
Unknown option: f
CPAN: Storable loaded ok
Going to read /Users/Mac/.cpan/Metadata
^C
~ $ sudo /usr/bin/cpan -f -i App::cpanminus
Unknown option: f
CPAN: Storable loaded ok
Going to read /Users/Mac/.cpan/Metadata
Database was generated on Thu, 09 Dec 2021 18:17:02 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
http://www.cpan.org/authors/01mailrc.txt.gz
Going to read /Users/Mac/.cpan/sources/authors/01mailrc.txt.gz
Fetching with LWP:
http://www.cpan.org/modules/02packages.details.txt.gz
Going to read /Users/Mac/.cpan/sources/modules/02packages.details.txt.gz
Database was generated on Fri, 10 Dec 2021 19:29:02 GMT
There's a new CPAN.pm version (v2.29) available!
[Current version is v1.7602]
You might want to try
install Bundle::CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running...
Fetching with LWP:
http://www.cpan.org/modules/03modlist.data.gz
Going to read /Users/Mac/.cpan/sources/modules/03modlist.data.gz
Going to write /Users/Mac/.cpan/Metadata
App::cpanminus is up to date.
And surely enough there's still no cpanm installed.
Edit 2
Output of the cpan -D App::cpanminus (only the meaningful lines included)
Would you like to configure as much as possible automatically? [yes] yes
Reading '/Users/Mac/.cpan/Metadata'
Database was generated on Fri, 10 Dec 2021 19:29:02 GMT
App:cpanminus
-------------------------------------------------------------------------
(no description)
M/MI/MIYAGAWA/App-cpanminus-1.7044.tar.gz
(no installation file)
Installed: not installed
CPAN: 1.7044 Not up to date
Tatsuhiko Miyagawa (MIYAGAWA)
miyagawa#bulknews.net
A few things to note:
The cpan output should tell you where it installed things. Do you have the output? To try again, you can force install with cpan -f to see what happened.
The .cpan/ directory is just a work directory for CPAN.pm. However, you can go into its build/ directory and find the directory for the thing you are having trouble with to look at its build files. The Makefile will have settings such as INSTALLBIN and INSTALLSITEBIN (and some others) that notes where it decided to install things. Apple has typically set these to whatever they wanted for you already, so it's slightly different than the default perl behavior.
You've likely installed the cpanm script in one of perl's directories. Perl modules typically do not install into a common directory without you doing something special. There's likely a bin directory at the same level as the lib/ directory. See where you installed the module and then look for that bin/
$ cpan -D App::cpanminus
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/Users/brian/.cpan/Metadata'
Database was generated on Fri, 10 Dec 2021 19:29:02 GMT
App::cpanminus
-------------------------------------------------------------------------
(no description)
M/MI/MIYAGAWA/App-cpanminus-1.7044.tar.gz
/usr/local/perls/perl-5.34.0/lib/site_perl/5.34.0/App/cpanminus.pm
Installed: 1.7044
CPAN: 1.7044 up to date
Tatsuhiko Miyagawa (MIYAGAWA)
miyagawa#bulknews.net
$ ls -l /usr/local/perls/perl-5.34.0/bin/cpanm
-r-xr-xr-x 1 brian wheel 302800 Jun 23 18:53 /usr/local/perls/perl-5.34.0/bin/cpanm
I like to leave the Perl programs in that bin directory and make links to them if I want them somewhere else in my path (Make links to per version tools.
The -i switch to cpan is just extra typing. It's implied in almost every case where you would use it.
You get the permission error because you are using the system Perl and installing things into the directories it set up. Apple is pretty good about segregating that, but I don't remember how well they were doing that back then. A system update (heh, in your case unlikely ;) might overwrite or delete your work. Many people use a separate, user-installed perl and pretend the system perl does not exist.

Perl not recognizing module / module path for root user

I am new to Perl so please bear with me. Thank you for your assistance.
I have an Ubuntu machine with Perl on it. I followed the local::lib bootstrapping guide
I used cpanm to install DBI and other modules to my system. I am concerned there may be other DBI modules available on my system which could be part of the problem. This is the result of find / -name 'DBI.pm' 2>/dev/null:
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/blib/lib/DBI.pm
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/blib/lib/Bundle/DBI.pm
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/DBI.pm
/home/ubuntu/.cpanm/work/16125643.6178/DBI-1.643/lib/Bundle/DBI.pm
/home/ubuntu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/DBI.pm
/home/ubuntu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/Bundle/DBI.pm
I added 2 lines to my .bashrc file. (I added the second line because I broke things for the non-root user and this fixed it; maybe I broke something with local::lib?)
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
PERL5LIB="/home/ubuntu/perl5/lib/perl5"
I can run my perl script as a non-root user.
If I run with sudo perlScript.pl I get this error: Can't locate DBI.pm in #INC (you may need to install the DBI module)
I have been troubleshooting #INC for a while now and cannot figure out how to adjust it for the root user. I have tried various things including adding PERL5LIB to .profile and calling my script like so: sudo sh -c '. ~/.profile; perl ~/perlScripts/perlScript.pl "argForScript"' (I verified that PERL5LIB is being set with sudo sh -c '. ~/.profile; echo $PERL5LIB')
However I always get the #INC error. The most obvious thing I have noticed is comparing sudo perl -V and perl -V. The sudo call does not show any ENV vars and the #INC does not include the desired PERL5LIB location. The non-sudo call does show the desired ENV and #INC vars.
I am considering wiping things and doing a fresh install with root privileges for local::lib and cpan. Not really sure what else to try at this point.
These are the commands that ended up working for me. I corrupted my first environment with local::lib / non-sudo cpan install, so I setup a fresh VM.
sudo apt install make
sudo apt install build-essential
sudo apt install libmysqlclient-dev
sudo cpan App::cpanminus
cpanm --sudo DBI
cpanm --sudo Array::Utils
cpanm --sudo DBD::mysql

perl cpan installation error

I tried installing cpan for strawberry perl with following cpan App::cpanminus.
But following is the error I got. Could you please guide how can I resolve this issue?
C:\Strawberry\perl\bin>cpan app::cpanminus
CPAN: CPAN::SQLite loaded ok (v0.204)
Database was generated on Thu, 02 Apr 2015 07:11:45 GMT
Warning: Cannot install app::cpanminus, don't know what it is.
Try the command
i /app::cpanminus/
to find objects with matching identifiers.
CPAN: Time::HiRes loaded ok (v1.9726)
C:\Strawberry\perl\bin>i /app::cpanminus/
'i' is not recognized as an internal or external command,
operable program or batch file.
To install it without using cpan, the basic bootstrap procedure is:
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
For more information see the installation section at App::cpanminus

Enabling PNG support while installing GD.pm in Perl

I have already installed GD.pm. I want to make sure it supports PNG.
So to check that I do this:
$ perl -e 'use GD; $im=GD::Image->new(); print $im->can("png") ? "yes" : "no" , "\n";'
no
As you see. It prints no.
Then I download the latest GD from CPAN with the following process:
> wget http://search.cpan.org/CPAN/authors/id/L/LD/LDS/GD-2.53.tar.gz
> tar xvfz GD-2.53.tar.gz
> cd GD-2.44
> perl Makefile.PL
> make
> make test
> make install
I expect it to contain the line like this which is a hallmark of the installed PNG support:
Included Features: GD_XPM GD_JPEG GD_FONTCONFIG GD_FREETYPE
GD_PNG GD_GIF GD_GIFANIM GD_OPENPOLYGON GD_UNCLOSEDPOLY GD_ANIMGIF
GD_FTCIRCLE VERSION_33
But instead I got this only:
Included Features: GD_GIF GD_GIFANIM GD_OPENPOLYGON
I wasn't successful with this command either sudo perl Makefile.PL -options "JPEG,FT,PNG".
It didn't show GD_PNG.
What's the way to install GD.pm with PNG support?
I need it to run circos.
Update:
After installing libpng and rebuilding GD
$ brew update && brew upgrade
$ brew install gd
$ brew install libpng
$ sudo cpan
cpan > force install GD
as adviced, I got this error:
$ perl -e 'use GD; $im=GD::Image->new(); print $im->can("png") ? "yes" : "no" , "\n";'
Can't load '/Library/Perl/5.16/darwin-thread-multi-2level/auto/GD/GD.bundle' for module GD: dlopen(/Library/Perl/5.16/darwin-thread-multi-2level/auto/GD/GD.bundle, 1): Library not loaded: libpng15.15.dylib
Referenced from: /usr/local/lib/libfreetype.6.dylib
Reason: image not found at /System/Library/Perl/5.16/darwin-thread-multi-2level/DynaLoader.pm line 194.
at -e line 1.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Update 2:
Finally I fixed the problem by doing this:
$ locate libpng15.15.dylib
/anaconda/lib/libpng15.15.dylib
/anaconda/pkgs/libpng-1.5.13-1/lib/libpng15.15.dylib
/opt/X11/lib/libpng15.15.dylib
/opt/local/lib/libpng15.15.dylib
$ ln -s /opt/X11/lib/libpng15.15.dylib /usr/local/lib/libpng15.15.dylib
$ perl -e 'use GD; $im=GD::Image->new(); print $im->can("png") ? "yes" : "no" , "\n";'
yes
You need libraries as dependencies before making GD.pm. In this particular case libpng is obviously missing.
Because of that dependency, I recommend that you use package managers, not CPAN, if your perl is the one that comes with your OS:
MacPorts or homebrew for OS X
apt-get for Debian and Ubuntu.
yum for RHEL, Cent-OS.

Need help installing Spreadsheet::ParseExcel

I am trying to install Spreadsheet::ParseExcel to use with ExcelLatex. This is what I did:
Installed Active perl, Then install CPAN.pm by perl -MCPAN -e shell
I was asked for configuration and mirror site and I let perl do the auoconfoguration. At the end I got the following message: Autoconfiguration complete.Then I tried:
perl -MCPAN -e 'install "Spreadsheet::WriteExcel"'
And it tried to install it but at the end I got the following error:
ERROR: Can't create '/Library/Perl/5.12/Spreadsheet'
mkdir /Library/Perl/5.12/Spreadsheet: Permission denied at /System/Library/Perl/5.12/ExtUtils/Install.pm line 494
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1
make: *** [pure_site_install] Error 13
JMCNAMARA/Spreadsheet-WriteExcel-2.37.tar.gz
/usr/bin/make install -- NOT OK
I really appreciate it one please help me how I can solve the problem
It is trying to create a directory in the root (mkdir /Library/Perl/5.12/Spreadsheet)
You have to be root to be able to do that.
You may could use PerlBrew or local::lib to install your perl libs into your home dir.
# Install Spreadsheet::WriteExcel and its missing dependencies to the '~/perl5' directory
perl -MCPAN -Mlocal::lib -e 'CPAN::install(Spreadsheet::WriteExcel)'
# Just print out useful shell commands
$ perl -Mlocal::lib
export PERL_MB_OPT='--install_base /home/username/perl5'
export PERL_MM_OPT='INSTALL_BASE=/home/username/perl5'
export PERL5LIB='/home/username/perl5/lib/perl5/i386-linux:/home/username/perl5/lib/perl5'
export PATH="/home/username/perl5/bin:$PATH"
#create a environment setting script and execute it.
perl -Mlocal::lib > ~/.setenv && . ~/.setenv
Regards,