Skip to content

Inconsistent behaviour of adding dependencies / pinning/ creating envs #6620

Description

@vigneshmanick

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:

pixi init
pixi add numpy
pixi add --feature test pytest
pixi workspace environment add default --solve-group default --feature test --force
pixi install

pixi.toml/pyproject.toml file that reproduces my issue:

[project]
name = "pixi-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = "==3.13"
dependencies = []

[tool.pixi.workspace]
channels = ["conda-forge"]
platforms = ["linux-64"]

[tool.pixi.pypi-dependencies]
pixi-test = { path = ".", editable = true }

[tool.pixi.tasks]

[tool.pixi.dependencies]
numpy = ">=2.5.1,<3"

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

[tool.pixi.environments]
default = { features = ["test"], solve-group = "default" }

pixi info output:


       TLS backend: rustls
           Platform: linux-64
   Virtual packages: __unix=0=0
                   : __linux=6.4.0=0
                   : __glibc=2.38=0
                   : __cuda=13.2=0
                   : __archspec=1=icelake
          Cache dir: /scratch/vm/dotdata/.cache/rattler/cache
       Auth storage: /home/vm/.rattler/credentials.json
   Config locations: No config files found

Global
------------
            Bin dir: /scratch/vm/tools/.pixi/bin
    Environment dir: /scratch/vm/tools/.pixi/envs
       Manifest dir: /scratch/vm/tools/.pixi/manifests/pixi-global.toml

Other files (e.g. script files, source files, etc.):

Issue description

Dependency pinning

When initializing a project and adding dependencies the main dependencies are pinned via semver but the other feature dependencies have latest version *. In above case, numpy and pytest have different pinning.

But when the dependency is removed from the list and readded via cli the the pinning reverts to semver

In the above example delete the line pytest = "*" and the run pixi add --feature test pytest, this will result in

[tool.pixi.feature.test.dependencies]
pytest = ">=9.1.1,<10"

Adding environment

When creating an environment via cli the messages are confusing

pixi add --feature test pytest
✔ Added pytest
Added these only for feature: test

pixi workspace environment add default --feature test --solve-group default --force
 WARN Encountered 1 warning while parsing the manifest:
  ⚠ The feature 'test' is defined but not used in any environment. Dependencies of unused features are not resolved or checked, and use wildcard (*) version specifiers by default, disregarding any set `pinning-
  │ strategy`
    ╭─[/scratch/vm/source/pixi-test/pyproject.toml:26:20]
 25 │ 
 26 │ [tool.pixi.feature.test.dependencies]
    ·                    ────
 27 │ pytest = "*"
    ╰────
  help: Remove the feature from the manifest or add it to an environment

The pyproject.toml gets updated with

[tool.pixi.environments]
default = { features = ["lint"], solve-group = "default" }

I just created an environment, why is there a warning that it's not used anywhere.

Expected behavior

  • The default dependencies and the feature dependencies have different pinning strategy, they should exhibit the same semver setting that is the default.
  • Adding a feature to the environments via cli is cumbersome since each change requires the --force argument, it will be much easier if there is an pixi workspace environment update command that can change existing environments
  • Creating environments should not result in warning about unused features that are used in the environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions