Skip to content

pixi install does not relink a moved environment and silently rewrites conda-meta/pixi_env_prefix #6990

Description

@nocnokneo

Checks

  • I have checked that this issue has not already been reported. Closest is No warning that my pixi environment is broken after copying it. #409 (2023), which is about the same symptom after copying an environment and, as far as I can tell, is what introduced the conda-meta/pixi_env_prefix marker.
  • I have confirmed this bug exists on the latest version of pixi, using pixi --version (0.79.0).

Reproducible example

mkdir -p /tmp/repro/a && cd /tmp/repro/a
cat > pixi.toml <<'TOML'
[workspace]
name = "relocate-repro"
channels = ["conda-forge"]
platforms = ["linux-64"]

[dependencies]
python = "3.12.*"
pip = "*"
TOML
pixi install
head -1 .pixi/envs/default/bin/pip
cat .pixi/envs/default/conda-meta/pixi_env_prefix; echo

mv /tmp/repro/a /tmp/repro/b && cd /tmp/repro/b
pixi -v install; echo "exit=$?"
head -1 .pixi/envs/default/bin/pip
cat .pixi/envs/default/conda-meta/pixi_env_prefix; echo
pixi run pip --version

Output:

The default environment has been installed.
#!/tmp/repro/a/.pixi/envs/default/bin/python3.12
/tmp/repro/a/.pixi/envs/default/conda-meta

 INFO pixi_core::lock_file::update: the lock file is up-to-date
 INFO pixi_core::lock_file::update: Installed environment 'default' in 3.643032ms
The default environment has been installed.
exit=0
#!/tmp/repro/a/.pixi/envs/default/bin/python3.12
/tmp/repro/b/.pixi/envs/default/conda-meta
Error launching 'pip': No such file or directory (os error 2)

Issue description

After the project directory moves, pixi install reports success and exits 0, but does not relink the environment. Every console-script shebang (and ipykernel's kernel.json) still points at the old prefix, so pixi run pip, jupyter, pytest and any notebook kernel fail with "bad interpreter" / "No such file or directory".

The part that turns this into a trap: pixi install rewrites conda-meta/pixi_env_prefix to the new location while doing nothing else. So the one piece of evidence that would let pixi (or a user) detect the relocation on the next run is destroyed on the first run. The binary does log "verifying prefix location is unchanged, with prefix file", so the check exists, but a mismatch neither triggers a reinstall nor produces a visible warning.

pixi run python keeps working, because PATH lookup execs the interpreter directly with no shebang involved. That makes the breakage easy to miss: we had an environment in a dev container whose mount point changed, and python worked for weeks while every entry point and kernel was broken. When we finally looked, pixi_env_prefix claimed the current path and 176 shebangs under bin/ disagreed.

pixi reinstall fixes the environment.

Expected behavior

When pixi_env_prefix does not match the environment's actual location, pixi install should relink the environment (what pixi reinstall does), or at minimum fail or warn loudly rather than silently updating the marker.

Environment

pixi 0.79.0, linux-64 (Ubuntu 24.04), packages from conda-forge.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions