I have created an conda environment and in that environment I have installed a tool called minibarcoder, which was developed by somebody else than me. https://github.com/asrivathsan/miniBarcoder
The tool is mostly a set of scripts (python or shell). To make it easy to use I moved all the scripts of the tool to the bin folder of the conda enviroment.
However, the miniBarcoder scripts in the bin folder depend on set of other scripts located in the folder scripts
. I moved that folder as well to the bin folder.
The folder scripts
contains some scripts, that I want to add to my $PATH
variable when using the environment and when I close the environment I want to remove those scripts from the PATH variable when I deactivate the environment.
As instructed by the conda manual (https://conda.io/docs/user-guide/tasks/manage-environments.html#macos-and-linux) , I can add the scripts folder to my PATH using an environment file that is located in the folder:
/work/projects/nn9305k/src/anaconda/envs/minibarcoder/etc/conda/activate.d
the file env_vars.sh
contains:
#!/bin/sh
#add scripts folder to PATH
export PATH=$PATH:/work/projects/nn9305k/src/anaconda/envs/minibarcoder/bin/scripts
When activating the environment it is the folder is added to the PATH variable.
Now my problem is how to remove this folder from the PATH variable when I deactivate the environment.
For that I create a file env_vars.sh
in the folder:
/work/projects/nn9305k/src/anaconda/envs/minibarcoder/etc/conda/deactivate.d
I have tried the following:
#!/bin/sh
#remove scripts from PATH
export PATH=$(echo ${PATH%:/work/projects/nn9305k/src/anaconda/envs/minibarcoder/bin/scripts
This does not remove the directory from the PATH variable, but when I run that command on the commandline, I do remove it from the PATH variable. Why is it not working in my env_vars.sh file.?
Any hints are welcome