'snakemake and conda environments

Question: how do I specify a conda environment with a distinct prefix in a snakemake rule without it crashing upon trying to deactivate the env?

background: I have conda environments stored in an alternate location (I made a given conda environment with conda create --prefix ./envname) than my baseline miniconda. I call these conda environments in their respective snakemake rules, as advised in the documentation.

rule hello: input: ... output: ... conda: "/path/to/conda/env" shell: "..."

I am unable to supply .yaml files to my Snakefile.

All my snakemake rules run beautifully. However, snakemake then tries to exit and does it using --name not --prefix

subprocess.CalledProcessError: Command 'conda env export --name '/path/to/env'' returned non-zero exit status     1.

Of course this will fail because conda environments referred to by 'name' can't have '/' in them.

So my snakemake crashes. My rules work great in the command line but I'm working with hundreds of samples so I need snakemake.

Also, I know people have said online that you can't do 'conda activate env' and that the workaround is to put a header saying 'source $HOME/miniconda3/etc/profile.d/conda.sh' which I have but this isn't fixing the issue because its within the Snakefile.

help! thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source