I'm running the following command in continuous integration (not locally on a machine):
conda env create -f python/env/foo.yml && conda init bash && conda activate foo
However, I'm getting the following error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Error: Process completed with exit code 1.
Since it's CI and I can't open a new shell in CI, how do I have the same effect so that I can use conda activate?
CodePudding user response:
The conda init command is for adding code to the shell resource file, providing functionality (like conda activate) for interactive shell sessions. Since CI sessions usually transient, one instead should just source the etc/profile.d/conda.sh directly to add conda activate support.
Something like:
conda env create -f python/env/foo.yml \
&& . "$(conda info --base)/etc/profile.d/conda.sh" \
&& conda activate foo
