Closed minrk closed 1 year ago
If I download the anaconda or miniconda distribution, install it in my user directory, and fire it up, the default is to be in the CONDA_ROOT environment, right? Isn't that one of the most common cases for using anaconda?
Yes, it's the most common and I think it shouldn't get treated like an env. That's why I think it's an important bug to fix.
A base anaconda install is more equivalent to a homebrew-installed Python than a virtualenv, in my mind.
Yes, it's the most common and I think it shouldn't get treated like an env. That's why I think it's an important bug to fix.
Okay, I agree. On the plus side, that makes the behavior for venv and conda consistent, i.e., the base install is not considered a preferred path.
I just installed a fresh install of miniconda on macos, and tried to see what CONDA_ROOT would give me.
Here is the base environment:
$ python -c "import os; print(*(f'{k}:{v}\n' for k,v in os.environ.items() if k[:4]=='COND'))"
CONDA_SHLVL:1
CONDA_EXE:/[my user directory]/opt/miniconda3/bin/conda
CONDA_PYTHON_EXE:/[my user directory]/opt/miniconda3/bin/python
CONDA_PREFIX:/[my user directory]/opt/miniconda3
CONDA_DEFAULT_ENV:base
CONDA_PROMPT_MODIFIER:(base)
and here is what a small test environment gives me
$ python -c "import os; print(*(f'{k}:{v}\n' for k,v in os.environ.items() if k[:4]=='COND'))"
CONDA_SHLVL:2
CONDA_EXE:/[my user directory]/opt/miniconda3/bin/conda
CONDA_PYTHON_EXE:/[my user directory]/opt/miniconda3/bin/python
CONDA_PREFIX:/[my user directory]/opt/miniconda3/envs/newenv
CONDA_DEFAULT_ENV:newenv
CONDA_PROMPT_MODIFIER:(newenv)
CONDA_PREFIX_1:/[my user directory]/opt/miniconda3
Where is CONDA_ROOT?
huh, I must have confused my own environment variables for conda's! I'll look again at detecting the root env the right way.
I think CONDA_ROOT may be years old and no longer used (it's in my bashrc). I cleared all conda envs and started fresh:
unset $(env | grep CONDA | cut -d= -f1)
source $PREFIX/etc/profile.d/conda.sh
conda activate base
env | grep CONDA
CONDA_EXE=/Users/minrk/conda/bin/conda
CONDA_PREFIX=/Users/minrk/conda
CONDA_PROMPT_MODIFIER=(base)
_CE_CONDA=
CONDA_SHLVL=1
CONDA_PYTHON_EXE=/Users/minrk/conda/bin/python
CONDA_DEFAULT_ENV=base
So the two logical choices are:
CONDA_DEFAULT_ENV=base
(base is a reserved name, you can't create another env with this name)I elected to consider CONDA_DEFAULT_ENV being unset to mean we're not in an env, because that should mean that conda activate
has not been called. I could go either way on that, but I went with lacking confidence that we are in an env should mean we don't opt-in to env behavior, rather than the other way around.
I'm happy to try out this and #323 and wait for feedback.
For the purposes of 'preferring env config', I don't think it makes sense to treat the conda root prefix as an environment. This is quite likely to be a shared, not writable installation, and it would be more consistent to be treated like any other base Python install.
related: #318