-
-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set CONDA_PROMPT_MODIFIER env var when activating conda environment #455
Comments
Are those ennvars a part of a public API? Who says you can rely on them being set? |
@native-api I have no idea? I'm not deeply versed in either project. All I did was observe the lack of a shell prompt being set in the env auto activated by Edit: It seems to be mentioned in the deepdives of 'what happens' here.. so.. I assume yes? It's also indirectly referenced here, with the conda config setting to control how the prompt is defined ( |
Looking at: And: I wonder if it might not even be better to just call When no conda env is active, and no env specified in the activate command: ⇒ conda shell.bash activate
PS1='(base) '
export PATH='/Users/devalias/.pyenv/versions/miniconda3-latest/bin:/Users/devalias/.pyenv/versions/miniconda3-latest/condabin:REDACTED'
export CONDA_PREFIX='/Users/devalias/.pyenv/versions/miniconda3-latest'
export CONDA_SHLVL='1'
export CONDA_DEFAULT_ENV='base'
export CONDA_PROMPT_MODIFIER='(base) '
export CONDA_EXE='/Users/devalias/.pyenv/versions/miniconda3-latest/bin/conda'
export _CE_M=''
export _CE_CONDA=''
export CONDA_PYTHON_EXE='/Users/devalias/.pyenv/versions/miniconda3-latest/bin/python' When no conda env is active, and an non-existing env (eg. ⇒ conda shell.bash activate noexist
EnvironmentNameNotFound: Could not find conda environment: noexist
You can list all discoverable environments with `conda info --envs`. When no conda env is active, and an existing env (eg. ⇒ conda shell.bash activate textgen
PS1='(textgen) '
export PATH='/Users/devalias/.pyenv/versions/miniconda3-latest/envs/textgen/bin:/Users/devalias/.pyenv/versions/anaconda3-2022.05/condabin:REDACTED
export CONDA_PREFIX='/Users/devalias/.pyenv/versions/miniconda3-latest/envs/textgen'
export CONDA_SHLVL='1'
export CONDA_DEFAULT_ENV='textgen'
export CONDA_PROMPT_MODIFIER='(textgen) '
export CONDA_EXE='/Users/devalias/.pyenv/versions/miniconda3-latest/bin/conda'
export _CE_M=''
export _CE_CONDA=''
export CONDA_PYTHON_EXE='/Users/devalias/.pyenv/versions/miniconda3-latest/bin/python' When conda env is already active (eg. ⇒ conda shell.bash activate textgen
PS1='(textgen) '
export PATH='/Users/devalias/.pyenv/versions/miniconda3-latest/envs/textgen/bin:/Users/devalias/.pyenv/versions/anaconda3-2022.05/condabin:REDACTED
export CONDA_SHLVL='1'
export CONDA_PROMPT_MODIFIER='(textgen) ' This is talked about in more detail here: |
So the real problem is the prompt not changing? It should, unless you have |
The 'real problem' is wanting to see consistent things happen whether I activate the conda environment manually using I would have expected The observed symptom was the prompt not changing, which led me to discover the other env vars not being changed in the same way either. Edit: For completeness, I did have |
Overview
When activating a
conda
environment manually (eg.conda activate textgen
), the followingCONDA_*
env vars are set in my environment:⇒ env | grep CONDA CONDA_EXE=/Users/devalias/.pyenv/versions/miniconda3-latest/bin/conda _CE_CONDA= CONDA_PYTHON_EXE=/Users/devalias/.pyenv/versions/miniconda3-latest/bin/python CONDA_SHLVL=1 CONDA_PROMPT_MODIFIER=(textgen) CONDA_DEFAULT_ENV=textgen CONDA_PREFIX=/Users/devalias/.pyenv/versions/miniconda3-latest/envs/textgen
Yet when I use
pyenv
/pyenv-virtualenv
to activate the conda environment, theCONDA_*
env vars are different:⇒ env | grep CONDA CONDA_EXE=/Users/devalias/.pyenv/versions/miniconda3-latest/bin/conda _CE_CONDA= CONDA_PYTHON_EXE=/Users/devalias/.pyenv/versions/miniconda3-latest/bin/python CONDA_SHLVL=0 CONDA_DEFAULT_ENV=textgen CONDA_PREFIX=/Users/devalias/.pyenv/versions/miniconda3-latest/envs/textgen
Diffing these it seems that
CONDA_SHLVL
changes from0
to1
, andCONDA_PROMPT_MODIFIER
isn't set:In the manually activated version, having
CONDA_PROMPT_MODIFIER
set tells my shell prompt to display the activatedconda
environment; yet the fact that this isn't set in the automatically activated environment makes it seem as though it isn't working properly, even though I can see that it is based on the activated python version/etc.It looks like changes would probably have to be made in the following files to implement this, though i'm not 100% sure how easy/hard it would be, or if there are other deeper places I would need to be looking also:
Issue Template
Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.
Prerequisite
pyenv-virtualenv
plugin only. Please refrain from reporting issues of other plugins here.Description
macOS Ventura 13.2.1 (22D68)
?x86_64?
pyenv 2.3.10
pyenv-virtualenv 1.1.5 (virtualenv unknown)
Python 3.10.9
pyenv: virtualenv: command not found
N/A
The text was updated successfully, but these errors were encountered: