prefix-dev / pixi

Package management made easy
https://pixi.sh
BSD 3-Clause "New" or "Revised" License
2.29k stars 135 forks source link

Confusing behaviour when removing a pypi dependency with a specified version #1567

Open lebrice opened 4 days ago

lebrice commented 4 days ago

Checks

Reproducible example

$ pixi add gym==0.26.2 --pypi
✔ Added gym==0.26.2
Added these as pypi-dependencies.
$ pixi remove gym
 WARN Dependency `gym` doesn't exist
✔ Removed gym
$ pixi remove gym==0.26.2
 WARN Dependency `gym` doesn't exist
✔ Removed gym
$ pixi remove gym==0.26.2 --pypi
✔ Removed gym==0.26.2
Removed these as pypi-dependencies.

Issue description

Related to #1312 and #1314 (I think)

I find it confusing (from a new user standpoint) that when adding a package from pypi (with a version string), it seems to be necessary to specify both the same version and the --pypi flag in order to remove it:

For example:

pixi add gym==0.26.2 --pypi
pixi remove gym
 WARN Dependency `gym` doesn't exist
✔ Removed gym

Adding the version number:

$ pixi remove gym==0.26.2
 WARN Dependency `gym` doesn't exist
✔ Removed gym==0.26.2

Finally, adding the version number and the --pypi flag seems to work correctly (but it shouldn't be necessary to do this, right?)

$ pixi remove gym==0.26.2 --pypi
✔ Removed gym==0.26.2
Removed these as pypi-dependencies.

Is this intended behaviour?

Expected behavior

$ pixi add gym==0.26.2 --pypi
✔ Added gym==0.26.2
Added these as pypi-dependencies.
$ pixi remove gym
✔ Removed gym==0.26.2
Removed these as pypi-dependencies.
olivier-lacroix commented 4 days ago

you should be able to remove a pypi dependency with $ pixi remove gym --pypi

lebrice commented 3 days ago

IMO it should be sufficient to just pixi remove gym no? Is there any case in which one should be allowed to have both conda and pipy versions of the same package installed?

olivier-lacroix commented 3 days ago

The same package would indeed not make much sense. However, it could be different packages, but with identical names.

This being said, maybe pixi should try removing as pypi if the conda one is not found ?