Fish: activating a conda env doesn't set CONDA_PREFIX or run its activate.d/deactivate.d scripts
维护者通常 1 天内回复
评估
调研方向
Read the pyenv-sh-activate and pyenv-sh-deactivate paths mentioned in the issue, then compare the Fish output with the existing Bash and Zsh behavior. Reproduce with a conda environment containing etc/conda/activate.d/*.fish and etc/conda/deactivate.d/*.fish scripts. Done means Fish activation sets CONDA_PREFIX and sources activation scripts, while deactivation sources its scripts and unsets the variable.
由索引模型根据 Issue 内容生成。
描述
Prerequisite
- Make sure no duplicated issue has already been reported in the pyenv-virtualenv issues. You should look in closed issues, too.
- Make sure you are reporting a problem in Pyenv-Virtualenv and not seeking consultation with Pyenv-Virtualenv use.
- GitHub issues are intended mainly for Pyenv-Virtualenv development purposes. If you are seeking help with Pyenv-Virtualenv use, check Pyenv-Virtualenv documentation, go to a user community site like Gitter, StackOverflow, etc, or to Discussions.
- Make sure your problem is not derived from packaging (e.g. Homebrew).
- Please refer to the package documentation for the installation issues, etc.
- Make sure your problem is not derived from other plugins.
- This repository is maintaining the
pyenv-virtualenvplugin only. Please refrain from reporting issues of other plugins here.
- This repository is maintaining the
Describe the bug
In Bash and Zsh, activating a conda environment with pyenv activate, or through auto-activation, exports CONDA_PREFIX and sources the package activation scripts in <env>/etc/conda/activate.d/*.sh. Deactivating sources <env>/etc/conda/deactivate.d/*.sh and unsets CONDA_PREFIX. This was added for #173.
In Fish, none of this happens:
pyenv-sh-activateonly sourcesetc/fish/conf.d/*.fish. It doesn't setCONDA_PREFIXand doesn't sourceetc/conda/activate.d/*.fish.pyenv-sh-deactivatedoes nothing for conda envs in Fish. The comment there saysconda doesn't support fish, but conda has supported Fish since 4.4. ItsFishActivatorsourcesetc/conda/activate.d/*.fishandetc/conda/deactivate.d/*.fish, and setsCONDA_PREFIXwithset -gx.
Some conda-forge packages ship .fish activation scripts next to the .sh ones to set variables they need, e.g. proj (PROJ_DATA, PROJ_NETWORK), udunits2 (UDUNITS2_XML_PATH) or esmf (ESMFMKFILE). Those scripts build their paths from $CONDA_PREFIX. So for Fish users, an env activated by pyenv-virtualenv is missing those variables, and CONDA_PREFIX itself isn't set either. Tools that look for the active conda env through it don't see one.
Expected: Fish behaves like Bash/Zsh. Activation sets CONDA_PREFIX and sources etc/conda/activate.d/*.fish. Deactivation sources etc/conda/deactivate.d/*.fish and unsets CONDA_PREFIX.
Reproduction steps
Take a conda env with a package activation script for each shell, e.g. etc/conda/activate.d/geo.fish containing set -gx GEO_DATA "$CONDA_PREFIX/share/geo" and etc/conda/activate.d/geo.sh containing export GEO_DATA="$CONDA_PREFIX/share/geo".
In Fish, with pyenv init and pyenv virtualenv-init loaded:
$ pyenv activate miniconda3-latest/envs/geo
$ echo "CONDA_PREFIX=$CONDA_PREFIX GEO_DATA=$GEO_DATA"
CONDA_PREFIX= GEO_DATA=
The same in Bash:
$ pyenv activate miniconda3-latest/envs/geo
$ echo "CONDA_PREFIX=$CONDA_PREFIX GEO_DATA=$GEO_DATA"
CONDA_PREFIX=/Users/me/.pyenv/versions/miniconda3-latest/envs/geo GEO_DATA=/Users/me/.pyenv/versions/miniconda3-latest/envs/geo/share/geo
The conda-related part of the generated code shows the difference:
$ PYENV_SHELL=fish pyenv sh-activate --quiet miniconda3-latest/envs/geo | grep -E 'CONDA|^source|^\. '
set -gx CONDA_DEFAULT_ENV "geo";
$ PYENV_SHELL=bash pyenv sh-activate --quiet miniconda3-latest/envs/geo | grep -E 'CONDA|^source|^\. '
export CONDA_DEFAULT_ENV="geo";
export CONDA_PREFIX="/Users/me/.pyenv/versions/miniconda3-latest/envs/geo";
. "/Users/me/.pyenv/versions/miniconda3-latest/envs/geo/etc/conda/activate.d/geo.sh";
Diagnostic details
- Platform information (e.g. Ubuntu Linux 20.04): macOS 27.0
- OS architecture (e.g. amd64): arm64
- pyenv version: 2.8.15
- pyenv-virtualenv version: master (6fb661f)
- Python version: Python 3 in the conda env
- virtualenv version (if installed): not relevant (conda env)
- Please attach the debug log of a faulty Pyenv invocation as a gist: not attached, the
pyenv sh-activateoutput above shows the missing commands and the cause is described above - fish version: 4.9.3
- 主要语言
- Shell
- 星标
- 6.7k
- 派生
- 433
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 11
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pyenv/pyenv-virtualenv 的其他 Issue
-
Document the virtualenv, activate and deactivate hooks可能已有人在做 @officialasishkumar 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
pyenv/pyenv-virtualenv#552 ·
维护者通常 1 天内回复
-
Creating a virtualenv from system leaves a self-referencing symlink inside it可能已有人在做 @dhananjay6561 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
pyenv/pyenv-virtualenv#548 · 1 条评论 ·
维护者通常 1 天内回复
-
virtualenv-delete with a trailing slash can remove all of $PYENV_ROOT/versions可能已有人在做 @dhananjay6561 于 4 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
pyenv/pyenv-virtualenv#546 · 1 条评论 ·
维护者通常 1 天内回复
-
`pyenv virtualenv (version) (name)` ignores specified version and uses homebrew's `python` version未关闭
难度 3/5 半天 新手友好度 55/100
pyenv/pyenv-virtualenv#531 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
pyenv/pyenv-virtualenv#524 · 5 条评论 ·
维护者通常 1 天内回复
查看 pyenv/pyenv-virtualenv 的全部 Issue
相似的 Issue
-
package-update
难度 1/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug client P3
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
automated issue report
难度 1/5 1 小时以内 新手友好度 70/100
rockerBOO/awesome-neovim#2642 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
rocky-linux/documentation#3569 · 4 条评论 ·
维护者通常 1 天内回复