Can't locate Bio/SeqIO.pm in #INC - perl

Hi I am trying to install VelvetOptimizer using docker. and it say Can't locate Bio/SeqIO.pm in #INC. It requires the following to be installed:
Velvet >= 0.7.51 ,Perl >= 5.8, BioPerl >= 1.4 and i have installed them
Please find the Dockerfile:
FROM amazonlinux
WORKDIR /shared
RUN yum -y install gcc
ADD http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz /shared
RUN tar -xzf perl-5.16.1.tar.gz
WORKDIR /shared/perl-5.16.1
RUN ./Configure -des -Dprefix=/shared/perl-5.16.1/localperl
RUN make
RUN make test
RUN make install
RUN echo “Perl Installation Complete”
ENV PATH=/shared/perl-5.16.1/localperl/bin/:${PATH}
WORKDIR /shared
ADD http://www.ebi.ac.uk/~zerbino/velvet/velvet_latest.tgz .
RUN tar -xvf /shared/velvet_latest.tgz
WORKDIR /shared/velvet_1.2.10/
RUN make
ENV PATH=${PATH}:/shared/velvet_1.2.10/
WORKDIR /shared
RUN echo "BIO PERL INSTALLATION"
RUN \wget -O - https://install.perlbrew.pl | bash
ENV PATH=${PATH}:/root/perl5/perlbrew/bin/
RUN perlbrew install-cpanm
RUN cpanm Bio::Perl
WORKDIR /shared
ADD http://www.vicbioinformatics.com/VelvetOptimiser-2.2.5.tar.gz .
RUN tar zxvf VelvetOptimiser-2.2.5.tar.gz
ENV PATH=${PATH}:/shared/VelvetOptimiser-2.2.4
When I run the command/shared/VelvetOptimiser-2.2.5/VelvetOptimiser.pl
I get the below error:
Error:
Can't locate Bio/SeqIO.pm in #INC (#INC contains: /shared/VelvetOptimiser-2.2.5 /shared/vcftools/src/perl /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 /shared/VelvetOptimiser-2.2.5/VelvetOpt/Assembly.pm line 238.
BEGIN failed--compilation aborted at /shared/VelvetOptimiser-2.2.5/VelvetOpt/Assembly.pm line 238.
Compilation failed in require at /shared/VelvetOptimiser-2.2.5/VelvetOptimiser.pl line 37.
BEGIN failed--compilation aborted at /shared/VelvetOptimiser-2.2.5/VelvetOptimiser.pl line 37.
But when I use "find" command: I am able to find the files.
./root/.cpanm/work/1501770319.1/BioPerl-1.007001/blib/lib/Bio/SeqIO.pm
./root/.cpanm/work/1501770319.1/BioPerl-1.007001/Bio/SeqIO.pm
./shared/perl-5.16.1/localperl/lib/site_perl/5.16.1/Bio/SeqIO.pm
I think its not be found in Perl's include path, which is represented by the variable named #INC.
Can anyone please let me know how to fix this issue. how to add it in perls include path.

Clearly, /shared/VelvetOptimiser-2.2.5/VelvetOptimiser.pl has
#!/usr/bin/env perl
as its shebang line. So, it will use the first perl it finds in the $PATH.
You likely have a perl in /usr/bin. In your Docker file, you have:
ENV PATH=${PATH}:/root/perl5/perlbrew/bin/
That is, you likely put /usr/bin ahead of the perlbrew directory. So, /usr/bin/env perl is picking up /usr/bin/perl and not the perl you installed via perlbrew (which is also where you installed your new perl).
So, try
ENV PATH=/root/perl5/perlbrew/bin/:${PATH}
In addition, I do not see you actually install a perl via perlbrew:
You need
perlbrew install 5.xx.x
perlbrew switch 5.xx.x
before installing cpanm and installing Bio::Perl.

Related

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 program can't load modules (CentOS 7)

I installed and used the program module-tools on several machines, but this time i can't get it to work (CentOS 7). One Problem is, that i have to call my programs with "perl test.pl" instead of just "test.pl".
The bigger problem is, that the program doesn't run, it stops with an error.
https://github.com/OTRS/module-tools
[root#localhost bin]# sudo -u otrs perl otrs.ModuleTools.pl Module::File::Link
Could not require Console::Command::List:
Attempt to reload Console/BaseCommand.pm aborted.
Compilation failed in require at /usr/share/perl5/vendor_perl/parent.pm line 20.
BEGIN failed--compilation aborted at /opt/module-tools/lib/Console/Command/List.pm line 16.
Compilation failed in require at /opt/module-tools/lib/System.pm line 60.
Anybody any ideas?
Edit: I installed the dependencies with cpanm.
It also looks like the program runs further as root. It should not run as root, so it closes with an error for that, but it loads the file it can't run as the other user
Edit2:
When i run "perl -V" it get a difference at the end.
Root:
Built under linux
Compiled at Jan 21 2019 22:09:19
%ENV:
PERL5LIB="/root/perl5/lib/perl5"
PERL_LOCAL_LIB_ROOT="/root/perl5"
PERL_MB_OPT="--install_base "/root/perl5""
PERL_MM_OPT="INSTALL_BASE=/root/perl5"
#INC:
/root/perl5/lib/perl5/5.16.3/x86_64-linux-thread-multi
/root/perl5/lib/perl5/5.16.3
/root/perl5/lib/perl5/x86_64-linux-thread-multi
/root/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
Other User:
Built under linux
Compiled at Jan 21 2019 22:09:19
#INC:
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.
Could this have something to do with that? Everything else from the output is identical.
RESOLVED!:
I installed the whole vm again, and this time i installed cpanm with
sudo yum install "perl(App::cpanminus)"
I don't remember how i did that before, but the last time i had to give cpanm a few settings and choose at one point "local::lib" instead of "sudo". I gues i should have chosen "sudo". But it wirks now, thanks
Install dependencies from cpanfile. If you have cpanm on your server, you can do it this way:
cd ./module-tools
cpanm -l ./deps --installdeps .
perl -I ./deps/lib/perl5/ ./bin/otrs.ModuleTools.pl
We can force cpanm to install all dependencies into chooses directory with -l flag, and than, we show to interpreter where is all dependencies with -I ./deps/lib/perl5/

Why does this docker-compose command fail while docker run command succeeds?

I have the following docker-compose.yml:
db:
image: postgres
search:
image: elasticsearch
web:
build: .
working_dir: /code
environment:
CATALYST_CONFIG_LOCAL_SUFFIX: development
volumes:
- .:/code
ports:
- "8000:8000"
links:
- db
- search
command: carton exec plackup -E development bicycleevents_web.psgi -p 8000
Edit: and the following Dockerfile:
FROM ubuntu:latest
RUN apt-get update
RUN apt-get install -y --force-yes build-essential curl libssl-dev postgresql-client libpq-dev perl-doc
RUN apt-get clean
RUN curl -L https://cpanmin.us | perl - --sudo App::cpanminus
RUN cpanm Carton
RUN mkdir /code
WORKDIR /code
ADD . /code/
RUN rm -rf /code/local/
RUN carton install
If I run docker-compose up the carton exec ... command fails:
$ docker-compose up
...
Starting bicycleeventsweb_web_1
web_1 | Error while loading /code/bicycleevents_web.psgi: Can't locate Moose.pm in #INC (you may need to install the Moose module) (#INC contains: /code/lib /code/local/lib/perl5 /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 /code/lib/BicycleEvents/Web.pm line 2.
web_1 | BEGIN failed--compilation aborted at /code/lib/BicycleEvents/Web.pm line 2.
web_1 | Compilation failed in require at /code/bicycleevents_web.psgi line 6.
web_1 | BEGIN failed--compilation aborted at /code/bicycleevents_web.psgi line 6.
bicycleeventsweb_web_1 exited with code 2
...
However, if I run the same command manually on the container, it succeeds:
$ docker run -i -t -e "CATALYST_CONFIG_LOCAL_SUFFIX=development" bicycleeventsweb_web carton exec plackup -E development bicycleevents_web.psgi -p 8000
...
HTTP::Server::PSGI: Accepting connections at http://0:8000/
Any thoughts on what is different between the two commands?
For reference carton is like Bundler for Perl. Using carton exec should setup the Perl environment so that the appropriate library paths are included that contain all the application specific dependencies - as works with the docker run command.
Can we see the Dockerfile that's being built, please? (I lack the reputation to ask in a comment. Edit: Thanks! )
(Edit:)
One difference I notice is that you're mounting . to /code in your docker-compose file, but you're not when running the command manually. I'm not familiar with Carton specifically, but if it's creating artifacts inside /code when you're executing carton install in the Dockerfile, you might be losing them as a result of your docker-compose volumes definition.

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.

Can't locate DBI.pm

I'm trying to launch this script:
#!/usr/bin/perl
use DBI;
my $dbh = DBI->connect( 'dbi:Oracle:host=lonlin2;sid=TIMFX1AD;port=1524','xbsesdbo','xbsesdbo123' ) || die ( $DBI::errstr . "\n" );
my $query= "SELECT * FROM product_elements WHERE element_id = 1001";
my $queryHandler= $dbh->prepare($query);
my $result= $queryHandler->execute();
open(fileHandler,"> note.txt");
print fileHandler "Risultato query: $result\n";
my $e= $dbh->disconnect();
close(fileHandler);
When I launch this script I receive this error:
Can't locate DBI.pm in #INC (#INC contains: /opt/perl_32/lib/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/5.8.3 /opt/perl_32/lib/site_perl/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/site_perl/5.8.3 /opt/perl_32/lib/site_perl /opt/perl_32/lib/vendor_perl/5.8.3/IA64.ARCHREV_0-thread-multi /opt/perl_32/lib/vendor_perl/5.8.3 /opt/perl_32/lib/vendor_perl .) at ./prova.pl line 3.
I've got all installed! DBI.pm is installed!
If you have root, type in console (Debian/Ubuntu):
sudo apt-get install libdbi-perl
If you don't have active perl (and hence don't have ppm), you can also get DBI like this:
perl -MCPAN -e 'install DBI'
You may need to install drivers for Postgres like this:
perl -MCPAN -e 'install DBD::Pg'
For redhat/centos users:
sudo yum -y install perl-DBI
DBI isn't in your #INC path, which tells perl where to look for custom modules. This is probably because you've installed them using the cpan tool as a non-root user, which won't have write access to the default include paths.
You will need to locate DBI.pm and other packages, and move them into your #INC path.
Alternatively, find the packages you've installed and add the install path into your library path, for one time use:
PERL5LIB=/path/to/modules perl yourscript.pl
And for a more permanent solution, add this to ~/.bashrc:
export PERL5LIB=/path/to/modules
For alpine users use perl-dbi: apk add perl-dbi
For arch linux users:
sudo pacman -S perl-dbi