I'm trying to install perl modules via cpanm inside conda environment with perl installed. The conda environment was build with following definition:
name: perl_env
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- perl=5.26
- perl-app-cpanminus
- perl-local-lib
- gcc_impl_linux-64
- gxx_linux-64
- openmpi=4.1.0
The environment results with the following packages installed:
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 1_gnu conda-forge
binutils_impl_linux-64 2.35.1 h193b22a_1 conda-forge
binutils_linux-64 2.35 hc3fd857_29 conda-forge
gcc_impl_linux-64 9.3.0 h28f5a38_17 conda-forge
gcc_linux-64 9.3.0 h7247604_29 conda-forge
gxx_impl_linux-64 9.3.0 h53cdd4c_17 conda-forge
gxx_linux-64 9.3.0 h0d07fa4_29 conda-forge
kernel-headers_linux-64 2.6.32 h77966d4_13 conda-forge
ld_impl_linux-64 2.35.1 hea4e1c9_1 conda-forge
libgcc-devel_linux-64 9.3.0 hfd08b2a_17 conda-forge
libgcc-ng 9.3.0 h5dbcf3e_17 conda-forge
libgfortran-ng 9.3.0 he4bcb1c_17 conda-forge
libgfortran5 9.3.0 he4bcb1c_17 conda-forge
libgomp 9.3.0 h5dbcf3e_17 conda-forge
libstdcxx-devel_linux-64 9.3.0 h4084dd6_17 conda-forge
libstdcxx-ng 9.3.0 h2ae2ef3_17 conda-forge
mpi 1.0 openmpi conda-forge
openmpi 4.1.0 h9b22176_1 conda-forge
perl 5.26.2 h36c2ea0_1008 conda-forge
perl-app-cpanminus 1.7044 pl526_1 bioconda
perl-carp 1.38 pl526_3 bioconda
perl-constant 1.33 pl526_1 bioconda
perl-cpan-meta 2.150010 pl526_0 bioconda
perl-cpan-meta-requirements 2.140 pl526_0 bioconda
perl-cpan-meta-yaml 0.018 pl526_0 bioconda
perl-data-dumper 2.173 pl526_0 bioconda
perl-encode 2.88 pl526_1 bioconda
perl-exporter 5.72 pl526_1 bioconda
perl-extutils-cbuilder 0.280230 pl526_1 bioconda
perl-extutils-makemaker 7.36 pl526_1 bioconda
perl-extutils-manifest 1.72 pl526_0 bioconda
perl-extutils-parsexs 3.35 pl526_0 bioconda
perl-file-path 2.16 pl526_0 bioconda
perl-file-temp 0.2304 pl526_2 bioconda
perl-getopt-long 2.50 pl526_1 bioconda
perl-ipc-cmd 1.02 pl526_0 bioconda
perl-json-pp 4.04 pl526_0 bioconda
perl-local-lib 2.000024 pl526_0 bioconda
perl-locale-maketext-simple 0.21 pl526_2 bioconda
perl-module-build 0.4224 pl526_3 bioconda
perl-module-corelist 5.20190524 pl526_0 bioconda
perl-module-load 0.32 pl526_1 bioconda
perl-module-load-conditional 0.68 pl526_2 bioconda
perl-module-metadata 1.000036 pl526_0 bioconda
perl-params-check 0.38 pl526_1 bioconda
perl-parent 0.236 pl526_1 bioconda
perl-perl-ostype 1.010 pl526_1 bioconda
perl-scalar-list-utils 1.52 pl526h516909a_0 bioconda
perl-text-abbrev 1.02 pl526_0 bioconda
perl-text-parsewords 3.30 pl526_0 bioconda
perl-version 0.9924 pl526_0 bioconda
sysroot_linux-64 2.12 h77966d4_13 conda-forge
zlib 1.2.11 h516909a_1010 conda-forge
The conda env was activated with:
source /igatech/rd/dev/miniconda3/bin/activate
conda activate perl_env
Then from the shell:
eval $(perl -I/igatech/rd/dev/snakemake-workflows/annotation-maker_p/local/perl5/lib/perl5 -Mlocal::lib=/igatech/rd/dev/snakemake-workflows/annotation-maker_p/local/perl5)
Then try install forks packages with cpanm:
env PERL5LIB="" PERL_LOCAL_LIB_ROOT="" PERL_MM_OPT="" PERL_MB_OPT="" cpanm --force --notest forks
--> Working on forks
Fetching http://www.cpan.org/authors/id/R/RY/RYBSKEJ/forks-0.36.tar.gz ... OK
Configuring forks-0.36 ... OK
==> Found dependencies: Acme::Damn
--> Working on Acme::Damn
Fetching http://www.cpan.org/authors/id/I/IB/IBB/Acme-Damn-0.08.tar.gz ... OK
Configuring Acme-Damn-0.08 ... OK
Building Acme-Damn-0.08 ... FAIL
! Installing Acme::Damn failed. See /home/mvidotto/.cpanm/work/1610645810.24326/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'Acme::Damn' is not installed
! Bailing out the installation for forks-0.36.
Looking at the error in more details:
tail /home/mvidotto/.cpanm/work/1610645810.24326/build.log
cp Damn.pm blib/lib/Acme/Damn.pm
Running Mkbootstrap for Damn ()
chmod 644 "Damn.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Damn.bs blib/arch/auto/Acme/Damn/Damn.bs 644
"/usr/bin/perl" "/igatech/rd/dev/snakemake-workflows/annotation-maker_p/tests/snakemake/.snakemake/conda/4520f5b9/lib/site_perl/5.26.2/ExtUtils/xsubpp" -typemap '/igatech/rd/dev/snakemake-workflows/annotation-maker_p/tests/snakemake/.snakemake/conda/4520f5b9/lib/5.26.2/ExtUtils/typemap' Damn.xs > Damn.xsc
Can't locate object method "new" via package "ExtUtils::ParseXS" at /igatech/rd/dev/snakemake-workflows/annotation-maker_p/tests/snakemake/.snakemake/conda/4520f5b9/lib/site_perl/5.26.2/ExtUtils/xsubpp line 51.
make: *** [Damn.c] Error 255
-> FAIL Installing Acme::Damn failed. See /home/mvidotto/.cpanm/work/1610645810.24326/build.log for details. Retry with --force to force install it.
-> FAIL Installing the dependencies failed: Module 'Acme::Damn' is not installed
-> FAIL Bailing out the installation for forks-0.36.
The same happens while installing different perl packages (DBI). I am not really able to overcome this error so I strongly ask for help, thank you in advice.
Yes, you are right! Within the activate conda perl_env I got strange behaviours. If I type:
which perl
/usr/bin/perl
if I type:
command -v perl
/igatech/rd/dev/snakemake-workflows/annotation-maker_p/tests/snakemake/.snakemake/conda/4520f5b9/bin/perl
or
whereis perl
perl: /usr/bin/perl /igatech/rd/dev/snakemake-workflows/annotation-maker_p/tests/snakemake/.snakemake/conda/4520f5b9/bin/perl /usr/share/man/man1/perl.1.gz
If I do:
perl --version
This is perl 5, version 26, subversion 2 (v5.26.2) built for x86_64-linux-thread-multi
Copyright 1987-2018, Larry Wall
...
or If I do:
/usr/bin/perl --version
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 40 registered patches, see perl -V for more detail)
Copyright 1987-2012, Larry Wall
...
To be honest it's known that in my system which command behaves strangely. I wouldn't like that this was the cause of the problem...
PS: conda env 4520f5b9 is same as perl_env
I can try answer the first part of the question: How to use the correct perl when installing packages in the conda environment. I am on Ubuntu 20.04:
/home/hakon/anaconda3cpan(this assumes that I did not have any previouscpanconfiguration (~/.cpan/) and local lib (~/perl5/) set up in my home directory). Choose thelocal::liboption below:Note that I answered "no" on the previous question.
env_vars.shfile:cpanmSo this fails. If I try to install the failing module
Acme::Damnmanually:It shows that
maketries to use a nonexistent C compiler:A clue to why this happens is given by the perl configuration data for
cc:I think that when perl tries to compile an XS module it uses the same C compiler that was used to compile
perlwith. But in this case that compiler does not exist any more, since conda installed (downloaded) a pre-compiled perl (so theccvariable refers to a compiler on another machine, the machine that was used to compileperlwith)Probably this means that you cannot (should not) install XS modules with a downloaded precompiled perl. I would recommend that you build perl from source on the same machine instead.
Edit
My bad, it is actually possible to install the same compiler that was used to build perl by running:
But still I am not able to make
perl Makefile.PLuse that version yet..Edit 2
Added follow-up question.
Edit 3
After applying the patch in the follow-up question, I was able to install the module: