I'm having trouble simply activating the base
environment. Here is a snippet from my recipe:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
auto-activate-base: true
activate-environment: base
- run: conda info
- run: conda env update -n base --file environment.yaml
I'm getting
Error: To activate "base" environment use the "auto-activate-base" action input!
How can I improve it to actually work?
Replace with:
- uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment.yaml
activate-environment: <name stated in environment.yaml>
auto-activate-base: false
- run: conda info
Thanks @jaimergp . What about the case that I don't have an environment name specified in environment.yaml
?
Can't you add any name to the file? If it's not in your repo, maybe patch it with echo "name: test" >> environment.yaml
before using setup-miniconda
?
@jaimergp Sure I could add in the CI recipe itself. I don't like to do it generally, I think it is needlessly limiting to specify the name in the environment file, and as far as I know it is perfectly fine for conda not to specify it.
More widely, shouldn't the action be able to deal with my setup too?
Hi @tdegeus thanks for the report. @jaimergp I can't recall now if we add the name "test" by default to the yaml file if name is not in there.
We need to double check.
It seems indeed that the 'default' environment name is test
in this case @goanpeca . But with the commands above I still don't get a correctly activated environment. Here are the details for https://github.com/tdegeus/shelephant/pull/12
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment.yaml
activate-environment: test
auto-activate-base: false
- run: conda info
The last command outputs:
active environment : None
user config file : /home/runner/.condarc
populated config files : /home/runner/.condarc
conda version : 4.8.3
conda-build version : not installed
python version : 3.8.3.final.0
virtual packages : __glibc=2.27
base environment : /usr/share/miniconda (writable)
channel URLs : https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/runner/conda_pkgs_dir
envs directories : /usr/share/miniconda/envs
/home/runner/.conda/envs
platform : linux-64
user-agent : conda/4.8.3 requests/2.23.0 CPython/3.8.3 Linux/5.4.0-1031-azure ubuntu/18.04.5 glibc/2.27
UID:GID : 1001:116
netrc file : None
offline mode : False
Indeed if I look after the lines that install the packages in environment.yaml
it is outputted that
# To activate this environment, use
#
# $ conda activate test
#
# To deactivate an active environment, use
#
# $ conda deactivate
Suggesting that the environment was not activated.
@tdegeus because of how github actions work, you need to specify extra arguments for the actions as described in the README for the different shells.
- name: Conda info
shell: bash -l {0}
run: conda info
If you do not use shell: bash -l {0}
assuming you are using bash, then the action will not be able to activate the environments correctly.
This is a knowns limitation, you can read more here
@goanpeca So I'd have to do that for every line in which I want to use the environment?
Before, I used some action that didn't have this limitation:
- uses: s-weigand/setup-conda@v1
- run: conda --version
- run: conda env update -n base --file environment.yaml
@tdegeus
So I'd have to do that for every line in which I want to use the environment?
Yes or use a default shell if all your stepps will use the same one, as explained on:
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_iddefaultsrun
Before, I used some action that didn't have this limitation:
Yes, that action is not properly activating environments.
@tdegeus https://github.com/conda-incubator/setup-miniconda/pull/96 adds information on what I explained on the comment.
I think we can close the issue. If this is not the case, please let us know what else we can do to improve the action.
Thanks again for the feedback :-)
Great @goanpeca , thanks for the help and for the PR!!
If I may give a personal experience on the readme while we close this question:
test
, I don't think I found that anywhere.
Most helpful comment
Great @goanpeca , thanks for the help and for the PR!!
If I may give a personal experience on the readme while we close this question:
test
, I don't think I found that anywhere.