Fish: activating a conda env doesn't set CONDA_PREFIX or run its activate.d/deactivate.d scripts

Aperta
#550 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@officialasishkumar ci sta già lavorando.

Dal 4/12/2026.

  • #551 di @officialasishkumar — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
fish, shell
Ambito
backend, cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
  • 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-virtualenv plugin only. Please refrain from reporting issues of other plugins here.
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-activate only sources etc/fish/conf.d/*.fish. It doesn't set CONDA_PREFIX and doesn't source etc/conda/activate.d/*.fish.
  • pyenv-sh-deactivate does nothing for conda envs in Fish. The comment there says conda doesn't support fish, but conda has supported Fish since 4.4. Its FishActivator sources etc/conda/activate.d/*.fish and etc/conda/deactivate.d/*.fish, and sets CONDA_PREFIX with set -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-activate output above shows the missing commands and the cause is described above
  • fish version: 4.9.3
Lingua principale
Shell
Stelle
6.7k
Fork
433
Merge medio
1g 8h
PR unite (30g)
11

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pyenv/pyenv-virtualenv

Tutte le issue di pyenv/pyenv-virtualenv

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.