Search code examples
perlcondaperl-module

Can't locate File/Slurp.pm in @INC in a conda installed program


I started getting in trouble with different programs installed using conda ('abricate', 'mlst') giving error messages with the Can't locate File/Slurp.pm in @INC. This occured after changing computers and having to reinstall different things and changing to anaconda3. As an example I get the following error message when trying to start abricate:

Can't locate File/Slurp.pm in @INC (you may need to install the File::Slurp module) 
(@INC contains: /anaconda3/lib/perl5/site_perl/5.22.0/darwin-thread-multi-2level /anaconda3/lib/perl5/site_perl/5.22.0 /anaconda3/lib/perl5/5.22.0/darwin-thread-multi-2level /anaconda3/lib/perl5/5.22.0 .) at /anaconda3/bin/abricate line 9.
BEGIN failed--compilation aborted at /anaconda3/bin/abricate line 9.

when I search for the install on my computer it is already present in multiple locations (some of which are empty?):

  • /anaconda3/pkgs/perl-file-slurp-9999.25-pl526_0/lib/site_perl/5.26.2/darwin-thread-multi-2level/auto/File/Slurp
  • /anaconda3/pkgs/perl-file-slurp-tiny-0.004-pl526_1/lib/site_perl/5.26.2/File/Slurp
  • /anaconda3/pkgs/perl-file-slurp-tiny-0.004-pl526_1/lib/site_perl/5.26.2/darwin-thread-multi-2level/auto/File/Slurp
  • /anaconda3/lib/site_perl/5.26.2/darwin-thread-multi-2level/auto/File/Slurp
  • /anaconda3/lib/site_perl/5.26.2/File/Slurp

I tried to reinstalling the slurp module

conda install -c bioconda perl-file-slurp

but that did not help.

I have tried to further understand how the @INC is build up. But I am confused about how this works with conda installed programs. When I look at the perl environment, I get different locations compared to the error message which specified different folders for the @INC.

$ env -i perl -V

Summary of my perl5 (revision 5 version 18 subversion 2) configuration:

  Platform:
    osname=darwin, osvers=18.0, archname=darwin-thread-multi-2level
    uname='darwin osx337.sd.apple.com 18.0 darwin kernel version 17.0.0: fri may 4 10:33:38 pdt 2018; root:xnu-4570.1.46.100.2~1development_x86_64 x86_64 '
    config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  -Dldflags= -Dman3ext=3pm -Duseithreads -Duseshrplib -Dinc_version_list=none -Dcc=cc'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags =' -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector',
    optimize='-Os',
    cppflags='-g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector'
    ccversion='', gccversion='4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector'
    libpth=/usr/lib /usr/local/lib
    libs= 
    perllibs=
    libc=, so=dylib, useshrplib=true, libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS
                        PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
                        PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
                        PERL_PRESERVE_IVUV PERL_SAWAMPERSAND USE_64_BIT_ALL
                        USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES
                        USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE
                        USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF
                        USE_REENTRANT_API
  Locally applied patches:
    /Library/Perl/Updates/<version> comes before system perl directories
    installprivlib and installarchlib points to the Updates directory
  Built under darwin
  Compiled at Aug 17 2018 17:29:08
  @INC:
    /Library/Perl/5.18/darwin-thread-multi-2level
    /Library/Perl/5.18
    /Network/Library/Perl/5.18/darwin-thread-multi-2level
    /Network/Library/Perl/5.18
    /Library/Perl/Updates/5.18.2
    /System/Library/Perl/5.18/darwin-thread-multi-2level
    /System/Library/Perl/5.18
    /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.18
    .

My path is as follows:

$ echo $PATH
/anaconda3/bin:/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/ncbi/blast/bin:/opt/X11/bin

I believe it is also possible to change the environment by adding things to the program itself

use lib '/anaconda3/lib/site_perl/5.26.2/darwin-thread-multi-2level';

but as I have the problem with multiple programs I would like to understand what the core problem is (except me being rather new to this...:)


Solution

  • It looks like you have messed up your system.

    If I interpret the messages correctly you have at least three different Perl installations:

    • 5.18.2 from your macOS Mojave (? osvers=18.0) installation
    • 5.22.0 from anaconda3
    • 5.26.2 from anaconda3???? (or only the packages, but not the perl binary itself)

    env -i CMD starts CMD with an empty environment, so it will remove anything you might have configured. So env -i perl -V will find the "default" perl in your system, which is the one from the macOS Mojave installation in /usr/bin/perl.

    But that perl doesn't cause the error message, so we can ignore it.


    When you execute conda ... it seems to use a perl 5.22.0 from /anaconda3. But at the same time you have installed perl 5.26.2 in that environment. My educated guess would be:

    • you had a failed install/update of the Anaconda 3 perl package, i.e. it already installed 5.26.2 packages, but not the binary and left the old perl 5.22.0 binary intact.
    • you didn't use the same channel for different conda install runs (your question indicates that you want to use the "bioconda" channel?)

    So the first thing you should try is in the same terminal you ran conda in:

    $ which perl
    $ perl -V
    

    How to fix this? Here are things I would try:

    • Try to update the Anaconda 3 perl package with conda update -c bioconda perl
    • Try to remove & reinstall the Anaconda3 perl package conda remove -c bioconda perl and conda install -c bioconda perl
    • The drastic approach: remove and reinstall Anaconda 3 from scratch, i.e. rm -rf /anaconda3, removing the PATH additions from ~/.bashrc and then closing the terminal.