# \`conda: command not found\` inside workflow task

**URL:** <https://cylc.discourse.group/t/conda-command-not-found-inside-workflow-task/962>\
**Category:** Cylc Support\
**Created:** [June 5, 2024, 8:58am UTC](https://cylc.discourse.group/t/conda-command-not-found-inside-workflow-task/962 "2024-06-05T08:58:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliotfontaine](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/elliotfontaine/32/380_2.png) [@elliotfontaine](https://cylc.discourse.group/u/elliotfontaine)\
**Post date:** [June 5, 2024, 8:58am UTC](https://cylc.discourse.group/t/conda-command-not-found-inside-workflow-task/962/1 "2024-06-05T08:58:35Z")

</div>

I’m not making this an issue on GitHub because this is probably me being stupid…

flow.cylc :

```ini
#!Jinja2

# Create task families for conda environments.
%include 'conda.cylc'

[scheduling]
    cycling mode = integer
    initial cycle point = 1
    [[graph]]
        P1 = raw_to_mzml
[runtime]
    [[raw_to_mzml]]
        inherit = None, CONDA_TRFP
        script = thermorawfileparser --help

```

conda.cylc :

```ini
#!Jinja2

{% set conda_envs = {
    'CONDA_TRFP': 'wf-trfp',
    'CONDA_BINNER': 'wf-binner',
    'CONDA_DATAMUNGING': 'wf-datamunging',
    'CONDA_INFLUX': 'wf-influx'
    } %}

[runtime]
{% for env, conda_env_name in conda_envs.items() %}
    [[{{env}}]]
        pre-script = """
            set +eu
            conda activate {{ conda_env_name }}
            set -eu
        """
{% endfor %}

```

job.err

```auto
/home/fontain/cylc-run/test-conda/run1/log/job/1/raw_to_mzml/01/job: line 44: conda : command not found
/home/fontain/cylc-run/test-conda/run1/log/job/5/raw_to_mzml/01/job: line 50: thermorawfileparser : command not found
2024-06-05T10:14:34+02:00 CRITICAL - failed/ERR

```

As a sanity check, I added a` echo $PATH` and `echo $USER` to the pre-script. It’s indeed my user, but `condabin` isn’t added to the path.

This is a global conda install (root-owned, with group ‘conda’ which my username is in). But the issue started before that, with a local `$HOME/miniforge3`. So I tried reinstalling conda to solve it.

\_  
My .bashrc :

> **Summary**
>
> ```bash
> # >>> conda initialize >>>
> # !! Contents within this block are managed by 'conda init' !!
> __conda_setup="$('/var/local/miniforge3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
> if [$? -eq 0]; then
> eval "$__conda_setup"
> else
> if [-f "/var/local/miniforge3/etc/profile.d/conda.sh"]; then
> . "/var/local/miniforge3/etc/profile.d/conda.sh"
> else
> export PATH="/var/local/miniforge3/bin:$PATH"
> fi
> fi
> unset __conda_setup
> # <<< conda initialize <<<
> 
> # Toggle specific Cylc Flow version (select corresponding conda environment)
> unset CYLC_VERSION
> export CYLC_VERSION=8.2.4
> 
> ```

\_

My cylc wrapper:

> **Summary**
>
> ```bash
> ##############################!!! EDIT ME !!!##################################
> # Centrally installed Cylc releases:
> CYLC_HOME_ROOT="${CYLC_HOME_ROOT:-/opt}"
> 
> # Users can set CYLC_HOME_ROOT_ALT as well (see above), e.g.:
> CYLC_HOME_ROOT_ALT=/var/local/miniforge3/envs
> 
> # Global config locations for Cylc 8 & Rose 2 (defaults: /etc/cylc & /etc/rose)
> # export CYLC_SITE_CONF_PATH="${CYLC_SITE_CONF_PATH:-/etc/cylc}"
> # export ROSE_SITE_CONF_PATH="${ROSE_SITE_CONF_PATH:-/etc/rose}"
> ###############################################################################
> 
> ```

\_

Versions:

> **Summary**
>
> ```sh
> fontain@server:~$ cylc version --long
> 8.2.4 (/var/local/miniforge3/envs/cylc-8.2.4)
> 
> Plugins:
> cylc-rose 1.3.3 /var/local/miniforge3/envs/cylc-8.2.4/lib/python3.9/site-packages
> cylc-uiserver 1.4.4 /var/local/miniforge3/envs/cylc-8.2.4/lib/python3.9/site-packages
> 
> Entry Points:
> cylc.command:
> gui = cylc.uiserver.scripts.gui:main
> hub = cylc.uiserver.scripts.hub:main [hub]
> hubapp = cylc.uiserver.scripts.hubapp:main [hub]
> cylc.post_install:
> rose_opts = cylc.rose.entry_points:post_install
> 
> ```

---

<div class="post-metadata">

**Author:** ![oliver.sanders](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/oliver.sanders/32/110_2.png) [@oliver.sanders](https://cylc.discourse.group/u/oliver.sanders)\
**Post date:** [June 5, 2024, 9:44am UTC](https://cylc.discourse.group/t/conda-command-not-found-inside-workflow-task/962/2 "2024-06-05T09:44:00Z")

</div>

Hi,

The `script`, `pre-script`, etc that you configure is run in a Bash “login shell” environment.

This means that your `~/.bash_profile` file should be sourced (automatically by Bash), which is usually configured to source your `~/.bashrc` file which should in turn source the `conda.sh` script which provides Conda.

So this should work, I have workflows configured this way, but worth checking that the chain of assumptions holds.

---

<div class="post-metadata">

**Author:** ![elliotfontaine](https://yyz2.discourse-cdn.com/free1/user_avatar/cylc.discourse.group/elliotfontaine/32/380_2.png) [@elliotfontaine](https://cylc.discourse.group/u/elliotfontaine)\
**Post date:** [June 5, 2024, 11:55am UTC](https://cylc.discourse.group/t/conda-command-not-found-inside-workflow-task/962/3 "2024-06-05T11:55:05Z")

</div>

My .bashrc had the ‘interactive’ guard at the top:

```auto
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

```

🤦‍♂️

Thank you Oliver. I’m glad I didn’t make it a GitHub issue.
