I'd like to override some perl modules from a perl tool installed via conda. Perl is v5.26.2 installed via conda-forge.
However, I cannot overwrite any scripts which are located in the same directory as $SCRIPT because perl always prepends the location of the script to the module directories:
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0/modules
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0
/home/user/.local/lib/perl5/lib/perl5/x86_64-linux-thread-multi
/home/user/.local/lib/perl5/lib/perl5
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2
/opt/anaconda/envs/vep-99/lib/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/5.26.2
.
I now did a very ugly hack which simply changes the working directory for perl:
#!/bin/bash
SCRIPT="${SCRIPT:-vep}"
SCRIPT_DIR="$(dirname $(realpath $(which $SCRIPT)))"
export PERL5LIB="$PERL5LIB:$SCRIPT_DIR:$SCRIPT_DIR/modules"
cd /
# fake script location to be in the current working directory
cat $(which $SCRIPT) | perl $@
This results in the following @INC:
//modules
/
/home/user/.local/lib/perl5/lib/perl5/x86_64-linux-thread-multi
/home/user/.local/lib/perl5/lib/perl5
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0/modules
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2
/opt/anaconda/envs/vep-99/lib/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/5.26.2
.
This technically works, but there is still /, //modules and . in the include path.
Is there a way to get rid of that?
which $SCRIPTtoperl. It is not clear why you do thatdirname $SCRIPTas well as$(dirname $SCRIPT)/moduleas the top-most entries in @INC. By piping the script into perl, I fake the location of the script to be $PWD. Does this make sense to you @Hakon?export PERL5LIBI getPERL5LIB=/home/user/[...]:/opt/anaconda/envs/vep-99/share/[...]:/opt/anaconda/envs/vep-99/lib/[...]. However, inside the Perl process I get something like@INC=/modules:/:/home/user/[...]:/opt/anaconda/envs/vep-99/share/[...]:/opt/anaconda/envs/vep-99/lib/[...]. I.e. it prepends the current working directory, not?