Building from Singularity recipes problems - perl

I am a beginner in Singularity and I would like having help in building from a recipe.
I want to use GARM, a genome assemblies reconciliation tool, to reconciliate two genomes I have assembled. Since I am working on a HPC server, I don't have the permissions to install the required perl packages for this tool (which are Parallel::ForkManager and List::MoreUtils) and R. I found there are two possible solutions for that (and please tell me if I am wrong or if there are other things I can do):
install R and perl modules locally (but in this case I should change all the scripts references to them)
build a Singularity container containing all the dependencies needed and GARM, since the server has Singularity 2.6 installed.
I choosen the second solution and decided to use a recipe to build the container, which is the following:
Bootstrap: docker
From: ubuntu
%files
GARM_0.7.4
%post -c /bin/bash
apt-get update
apt-get install -y --force-yes perl build-essential cpanminus r-base
cpanm Parallel::ForkManager List::MoreUtils
export GARMBIN=/GARM_0.7.4/bin
export GARMLIB=/GARM_0.7.4/lib
export MUMBIN=/GARM_0.7.4/MUMmer3.22
export AMOSBIN=/GARM_0.7.4/amos-3.0.0/bin
export AMOSLIB=/GARM_0.7.4/amos-3.0.0/lib
%runscript
exec perl /GARM_0.7.4/GARM.pl
where GARM_0.7.4 is the folder downloaded containing everything the software needs, except R and perl modules.
I use sudo singularity build garm.simg recipe-garm to build the container.
Then using singularity run garm.simg --help to see if the container works, it comes out this:
Can't open perl script "/GARM_0.7.4/GARM.pl": Permission denied
Now, even if on the server I cannot use sudo, on my PC I tried anyway it with sudo singularity run garm.simg --help, and the output is:
Empty compile time value given to use lib at /GARM_0.7.4/GARM.pl line 12.
Can't locate GARM_main.pm in #INC (you may need to install the GARM_main module) (#INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /GARM_0.7.4/GARM.pl line 13.
BEGIN failed--compilation aborted at /GARM_0.7.4/GARM.pl line 13.
I don't know what is wrong. I can't get if the problem is the garm folder not copied inside the container so that the garm script can't be run, or if there are sintax problem in the recipe and the container does not run the script.
EDIT: added exports as README.txt from the tool suggests, but the situation does not change.

Related

perl DBI module installation erroring out

perl DBI module installation is erroring out.
Installed perl 5.32.1 in non standard location, using -Dinstallprefix option
./Configure -Dinstallprefix=/test/user/home/perl -des
make
make test
make install
/test/user/home/perl/bin/perl -version
This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux
Set PERL5LIB env variable
export PERL5LIB="/test/user/home/perl/lib/5.32.1:/test/user/home/perl/lib/site_perl/5.32.1:/test/user/home/perl/lib/5.32.1/x86_64-linux"
which perl
/test/user/home/perl/bin/perl
Downloaded DBI-1.643 archive, after extraction execution of Makefile.PL is failing
perl Makefile.PL
Warning: PERL_LIB (/perl/lib/5.32.1) seems not to be a perl library directory
(strict.pm not found) at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Unix.pm line 1934.
Have /test/user/home/perl/lib/5.32.1/x86_64-linux
Want /perl/lib/5.32.1/x86_64-linux
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [x86_64-linux]
Config says: [x86_64-linux]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Can't stat /perl/lib/5.32.1: No such file or directory
at Makefile.PL line 280.
Can't stat /perl/lib/5.32.1/x86_64-linux: No such file or directory
at Makefile.PL line 280.
Failed to opendir '/perl/lib/5.32.1/x86_64-linux/CORE' to find header files: No such file or directory at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Any.pm line 3048.
Found non existing paths are referred from #INC
perl -e "print \"#INC\""
/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
Can someone guide me where from #INC getting these non existing paths
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
are there any way to restrict #INC to append non existing paths?
I think you want just -Dprefix=/.... There are other things that need to end up in the right place too. You shouldn't need to set PERL5LIB though because perl should be using your prefix as its default #INC. What does your perl -V show?
There is an installprefix, but it's aimed at compiling on one machine and installing on another. However, the INSTALL docs also recommend against using that. Is that what you are trying to do?
As for the other directories, the INSTALL docs describe the various directories that show up in #INC.
Thank you #brian for pointing me in right direction.
Following was the root cause behind #INC contains non existing directories.
Last time during perl installation at least one time I ran following command
./Configure -des -Dprefix=/perl
Use relocatable #INC? [n]
Pathname where the private library files will reside? (~name ok)
[/perl/lib/5.32.1]
Where do you want to put the public architecture-dependent libraries? (~name ok)
[/perl/lib/5.32.1/x86_64-linux]
Pathname for the site-specific library files? (~name ok)
[/perl/lib/site_perl/5.32.1]
Pathname for the site-specific architecture-dependent library files? (~name ok)
[/perl/lib/site_perl/5.32.1/x86_64-linux]
then executed make command. Later on make test failed for other error.
Then without running make distclean command, I re ran Configure with
-Dinstallprefix option
./Configure -Dinstallprefix=/test/user/home/perl -des
This populate #INC as follows
/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
To fix this issue executed following steps,
make distclean
./Configure -des -Dprefix=/test/user/home/perl -Dusethreads
now #INC is populated correct
#INC:
/test/user/home/perl/lib/site_perl/5.32.1/x86_64-linux-thread-multi
/test/user/home/perl/lib/site_perl/5.32.1
/test/user/home/perl/lib/5.32.1/x86_64-linux-thread-multi
/test/user/home/perl/lib/5.32.1
Now DBI installation ran successfully.

Installing Perl Module in specified directory

I am trying to install one of the Perl module in my server (ubuntu droplet from Digital Ocean). I wanted this module to be installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/ directory which I have already created.
This is specific to one module. I don't want to install it in default path like /usr/bin/perl. I wanted it to be installed in above mentioned path.
Here are the list of commands which I executed to install the Email::Reply perl module.
Downloaded module from metacpan
tar xvfz Email-Reply-1.204.tar.gz
cd Email-Reply-1.204/
perl Makefile.PL PREFIX=/home/vinod/my_test_folder/perl_practice/scripts/lib/
su
<password_for_root>
make
make test
make install
When I execute make install command the following output got displayed on terminal screen
Manifying 1 pod document
Installing /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/Email/Reply.pm
Installing /home/vinod/my_test_folder/perl_practice/scripts/lib/man/man3/Email::Reply.3pm
Appending installation info to /home/vinod/my_test_folder/perl_practice/scripts/lib//lib/x86_64-linux-gnu/perl/5.26.1/perllocal.pod
And I could see the module got installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/Email/Reply.pm path, which is not right path which I mentioned in PREFIX=.
Strange thing here I wrote one small script which uses Email::Reply module by mentioning module path in shebang line
Code below:
#!/usr/bin/perl -I/home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/
use EMail::Reply;
print "Hi\n";
still its throws an error
Can't locate EMail/Reply.pm in #INC (you may need to install the EMail::Reply module) (#INC contains: /home/vinod/my_test_folder/perl_practice/scripts/lib/share/perl/5.26.1/ /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.26.1 /usr/local/share/perl/5.26.1 /usr/lib/x86_64-linux-gnu/perl5/5.26 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.26 /usr/share/perl/5.26 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at test.pl line 3.
BEGIN failed--compilation aborted at test.pl line 3.
I want this module to be installed in /home/vinod/my_test_folder/perl_practice/scripts/lib/
How to achieve this. Please help me.
This is what local::lib can be used for, and cpanm supports it by default:
$ cpanm -l /home/vinod/my_test_folder/perl_practice/scripts Email::Reply
This will install it to /home/vinod/my_test_folder/perl_practice/scripts/lib/perl5.
Alternatively you can recreate the options local::lib sets for this case, the important one for this case is PERL_MM_OPT.
$ env PERL_MM_OPT='INSTALL_BASE=/home/vinod/my_test_folder/perl_practice/scripts' cpanm Email::Reply
Importantly, note that all of this is case sensitive, you must use Email::Reply;.

Making Perl CPAN's Pg module work on Amazon's AWS server

I´m trying to port a Perl legacy software to Amazon's AWS servers, but I keep running on problems when trying to make all the components I need work.
Currently, I have Perl up and running (version 5.16.3), and PostgreSQL (9.2.18) as my database with no problems. They both run fine separately, but I simply can't make them work together.
This legacy software uses Pg library (I'm not referring to DBD::Pg, just Pg). However, I'm not able to run a script that references that specific library. I get the following error:
Can't locate loadable object for module Pg in #INC (#INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 /var/www/cgi-bin) at /var/www/cgi-bin/teste.pl line 8.
After some research, I understand that I'm somehow missing a dependency that Pg requires to work properly. I opened Pg.pm script to check which what it uses, and tried to import those through CPAN as well.
I managed to import Exporter and Carp successfully through cpan but DynaLoader simply won't install - apparently it needs to be compiled??
What do I need to do to properly install Pg?
I have never used Pg, so let's try on my ArchLinux install.
$ curl -O https://cpan.metacpan.org/authors/id/M/ME/MERGL/pgsql_perl5-1.9.0.tar.gz
$ tar xvf pgsql_perl5-1.9.0.tar.gz
$ cd pgsql_perl5-1.9.0
$ perl Makefile.PL
$ perl Makefile.PL
Configuring Pg
Remember to actually read the README file !
please set environment variables POSTGRES_INCLUDE and POSTGRES_LIB
So, if you installed Pg, you had to have set those variables. Simplest would be to install your chosen distro's package for those libraries. On ArchLinux, the following command installs them for me:
$ sudo pacman -S postgresql-libs
Then:
$ POSTGRES_INCLUDE=/usr/include POSTGRES_LIB=/usr/lib perl Makefile.PL
Configuring Pg
Remember to actually read the README file !
OS: linux
Generating a Unix-style Makefile
Writing Makefile for Pg
Writing MYMETA.yml and MYMETA.json
The build works but I can't test because I do not have a Postgresql instance to connect to. However, this works:
$ perl -I blib/lib -I blib/arch -e 'use Pg; print "ok\n"'
ok
Note the -I switches above would not have been necessary had I chosen to install this module that was last updated 17 years ago.

Module Installation errors when trying to use local::lib and CPAN

I am trying to use local::lib as I don’t have admin rights on the system and I want to download and install a local library. I ran following:
perl Makefile.PL --bootstrap
make test && make install
echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc
After this I tried to download the Module via cpan
by running perl -MCPAN -e shell install netAddr::IP but when i am running my program it's giving an error:
Can't locate NetAddr/IP.pm in #INC (#INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at agha.pl line 8.
BEGIN failed--compilation aborted at agha.pl line 8.
I took that to mean the module is not installed... So I again tried to go through CPAN, but now it's giving an error (this is in Linux):
-bash-3.2$ perl -MCPAN -e shell
There seems to be running another CPAN process (pid 15611). Contacting...
Other job is running.
You may want to kill it and delete the lockfile, maybe. On UNIX try:
kill 15611
rm /homes/ar312/.cpan/.lock
From the local::lib documentation:
After writing your shell configuration file, be sure to re-read it to get the changed settings into your current shell's environment.
You forgot to do so.
In all seriousness, save yourself a ton of time and trouble by installing perlbrew.
perlbrew is a tool to manage multiple perl installations in your $HOME directory. They are completely isolated perl universes. This approach has many benefits:
No need to run sudo to install CPAN modules, any more.
Try the monthly released new perls.
Learn new language features.
Test your production code against different perl versions.
Leave vendor perl (the one that comes with OS) alone

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