prefix-dev / pixi

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

Version pinning-strategy does not work well for the first dependency when trying to setup a new environment. #2524

Open ywilke opened 2 days ago

ywilke commented 2 days ago

Problem description

What I would like to be able to do: I would like to create a new environment like pixi project environment add --feature test test Even if the feature test might not exist yet. After creating the environment I want to add dependencies that have their versions pinned by the pixi pinning-strategy.

What I am currently doing: I am using the the Pixi CLI. To create an environment you first need to have an existing feature and to have an existing feature I first need to add a dependency to it. So I start with pixi add --feature test pytest Then I can create my environment pixi project environment add --feature test test The result is the following pixi.toml

[project]
authors = [" <>"]
channels = ["conda-forge"]
description = "Add a short description here"
name = "testing"
platforms = ["linux-64"]
version = "0.1.0"

[tasks]

[dependencies]

[feature.test.dependencies]
pytest = "*"

[environments]
test = ["test"]

So the pytest dependency did not get pinned by the pixi pinning-strategy but it is just set to *. Only after a feature is added to a environment the dependencies get pinned when added. So now I have to run pixi add --feature test pytest again so it gets pinned to ">=8.3.3,<9".

How can this be improved: If it was possible to create an environment for a feature that does not yet exist (by maybe creating an empty feature) I would not have to return the pixi add command to get a version pin for the dependencies that were added to the feature before it was added to an environment. Another option would be that the version pin of * would get updated using the pinning-strategy once a feature gets added to an environment. However, it would be impossible to know if the * was maybe intentionally set by the user.

I am also open to other suggestions. Love the work you are doing with Pixi!