Skip to content

global-ignore-conda-prefix leaves CONDA_SHLVL in trampoline env, causing invalid Conda activation state #6002

Closed

Description

@NeumoNeumo

Checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

Commands I ran and their output:

xjh@a6000-server:~$ pixi --version
pixi 0.67.2
xjh@a6000-server:~$ tmp="$(mktemp -d)"
export PIXI_HOME="$tmp/pixi"

env -u CONDA_SHLVL \
    -u CONDA_PREFIX \
    -u CONDA_DEFAULT_ENV \
    -u CONDA_PROMPT_MODIFIER \
    -u CONDA_EXE \
    pixi global install fish
└── fish: 4.6.0 (installed)
    └─ exposes: fish, fish_indent, fish_key_reader
xjh@a6000-server:~$ cat "$PIXI_HOME/bin/trampoline_configuration/fish.json"
{
  "exe": "/tmp/tmp.xQR2wOdbQ5/pixi/envs/fish/bin/fish",
  "path_diff": "/tmp/tmp.xQR2wOdbQ5/pixi/envs/fish/bin",
  "env": {
    "CONDA_SHLVL": "1"
  }
}

No pixi.toml/pyproject.toml file needed to reproduces my issue.

pixi info output:

$ pixi info
System
------------
       Pixi version: 0.63.2
        TLS backend: rustls
           Platform: linux-64
   Virtual packages: __unix=0=0
                   : __linux=6.8.0=0
                   : __glibc=2.35=0
                   : __cuda=12.4=0
                   : __archspec=1=cascadelake
          Cache dir: /home/xjh/.cache/rattler/cache
       Auth storage: /home/xjh/.rattler/credentials.json
   Config locations: No config files found

Global
------------
            Bin dir: /tmp/tmp.xQR2wOdbQ5/pixi/bin
    Environment dir: /tmp/tmp.xQR2wOdbQ5/pixi/envs
       Manifest dir: /tmp/tmp.xQR2wOdbQ5/pixi/manifests/pixi-global.toml

Issue description

The important part is that the generated trampoline configuration contains CONDA_SHLVL=1 but does not contain CONDA_PREFIX.

This becomes a practical problem when the globally installed executable is an interactive shell such as fish. For example, if ~/.pixi/bin/fish is used as a login shell or is executed from .bash_profile, the long-lived interactive shell inherits this invalid Conda state. Running conda activate base or equivalent activation logic can then fail because Conda sees a nonzero CONDA_SHLVL but cannot determine the active prefix.

The fish package appears to provide the global-ignore-conda-prefix marker:

find "$PIXI_HOME/envs/fish/etc/pixi" -type f -print
<tmp>/pixi/envs/fish/etc/pixi/fish/global-ignore-conda-prefix

And the problem arises from removing CONDA_PREFIX while preserving Conda stack variables such as CONDA_SHLVL

A possible implementation direction would be to extend the current global-ignore-conda-prefix handling from only removing CONDA_PREFIX (

env_for_trampoline.remove("CONDA_PREFIX");
) to also removing Conda stack variables from the trampoline env:

env_for_trampoline.remove("CONDA_PREFIX");
env_for_trampoline.remove("CONDA_SHLVL");
env_for_trampoline.remove("CONDA_DEFAULT_ENV");
env_for_trampoline.remove("CONDA_PROMPT_MODIFIER");

env_for_trampoline.retain(|key, _| {
    !key.starts_with("CONDA_ENV_SHLVL_")
});

Expected behavior

When etc/pixi/<executable>/global-ignore-conda-prefix is present, pixi should not write an incomplete Conda activation state into the trampoline configuration.

Activity

  1. added
    bug
    on May 4, 2026
  2. lucascolley commented on Oct 8, 2026

    @lucascolley
    Member

    fixed by gh-6210 I believe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions