pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Moving a dependency from `[pypi-dependencies]` to `[dependencies]` can silently delete its files from an existing environment

Open earlybard opened this issue 4 months ago • 2 comments

Checks

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

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

Reproducible example

[workspace]
name = "flip"
channels = ["conda-forge"]
platforms = ["linux-64"]

[dependencies]
python = "3.14.*"

[pypi-dependencies]
pystac = "==1.15.2"

On PyPI, pystac is split across pystac-core + 22 pystac-ext-* distributions that own site-packages/pystac/; conda-forge ships it as one package. Install, then flip it to [dependencies] pystac = "==1.14.3" and re-run:

$ pixi lock && pixi install     # warm, over the existing env
✔ The default environment has been installed.
$ pixi run python -c "import pystac"
ModuleNotFoundError: No module named 'pystac'
$ pixi list | grep '^pystac'
pystac  1.14.3  pyhd8ed1ab_0  135.46 KiB  conda  https://conda.anaconda.org/conda-forge

A same-named flip (e.g. click) is fine, and removing the PyPI dep without a conda replacement is fine — it needs both halves: a conda link plus a differently-named PyPI uninstall claiming the same paths.

Issue description

Moving a dependency from [pypi-dependencies] to [dependencies] and running pixi install over the existing environment can leave the package's files deleted while conda-meta and pixi list both say it's installed.

The removed PyPI distribution owns the same site-packages paths as the arriving conda package but under a different distribution name, so nothing connects the two. The conda package links first, then the PyPI uninstall walks the old RECORD and deletes the freshly-linked files.

Suggested Fix

The overlap accounting from #6292/#6344 looks reusable here: when unlinking a removed PyPI distribution, skip RECORD paths claimed by a conda package in the prefix's paths.json. Happy to open a PR for this.

Expected behavior

The warm install produces the same environment as a cold one: pystac 1.14.3 present and importable. The PyPI uninstall should leave any path alone once a conda package in the prefix claims it (per paths.json).

earlybard avatar Jul 30 '26 00:07 earlybard

Great catch! @tdejager has this already crossed your view? I think this is an interesting issue which might require some logistic changes that I'm personally not too familiar with.

ruben-arts avatar Jul 31 '26 09:07 ruben-arts

I reported this a while ago in #2203, and can confirm that it still exists. Also noted there that (EDIT: if you don't use pixi lock), running pixi install a second time will fix the package files.

jxu10 avatar Aug 12 '26 18:08 jxu10