Just a simple logic problem (you want to deactivate before you unload).
Try this:
if { [module-info mode remove] && ![module-info mode switch3] } {
puts stdout "conda deactivate"
}
module load conda
if { [module-info mode load] || [module-info mode switch2] } {
puts stdout "conda activate $path"
}
On 2022-01-04 04:43 AM, Marius Retegan wrote:
> Dear all,
>
> First of all happy new year and best wishes for 2022!
>
> I would like to use environment modules to load/unload Conda environments (https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-envs <https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-envs>).
>
> I have a working environment module for Conda alone. Now I need a module for a specific Conda environment. For this I use the code below to load/unload the environment:
>
> ## My conda environment module file
>
> module load conda
>
> if { [module-info mode load] || [module-info mode switch2] } {
> puts stdout "conda activate $path"
> } elseif { [module-info mode remove] && ![module-info mode switch3] } {
> puts stdout "conda deactivate"
> }
>
> If I do module load my_conda_environment; module unload my_conda_environment, I get an error because the conda dependency is unloaded first and then the conda command is not found anymore.
>
> However this works: module load conda; module load my_conda_environment; module unload my_conda_environemt; module unload conda.
>
> Is there a way to have the result of the previous line, without having to explicitly load conda? Thank you for your help.
>
> Best regards,
> Marius
>
>
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
>
--
--------------------------------------------------------
The views and opinions expressed above are strictly
those of the author(s). The content of this message has
not been reviewed nor approved by any entity whatsoever.
--------------------------------------------------------
Paul FM Info: http://paulfm.com/~paulfm/
--------------------------------------------------------
|