pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Confusing Ambiguous Environment Selection

Open dennis-wey opened this issue 1 year ago • 0 comments

Problem description

I find the current behavior confusing in which cases the interactive environment selection pops up when running pixi tasks. Some aspects:

  • if tasks are only available in a single environment that task is run in that environment -- this is clear behavior to me
  • if tasks are available in multiple environments and none of them is the default environment use interactive environment selection -- also clear behavior to me

However the behavior is confusing when there are multiple environments and one of them is the default one:

Using the docs, this triggers interactive environment selection when running pixi run ambi:

[project]
name = "test_ambiguous_env"
channels = []
platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"]

[tasks]
default = "echo Default"
ambi = "echo Ambi::Default"
[feature.test.tasks]
test = "echo Test"
ambi = "echo Ambi::Test"

[feature.dev.tasks]
dev = "echo Dev"
ambi = "echo Ambi::Dev"

[environments]
default = ["test", "dev"]
test = ["test"]
dev = ["dev"]

However pixi run ambi will run in default environment when using this version:

[project]
name = "test_ambiguous_env"
channels = []
platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"]

[tasks]
default = "echo Default"
ambi = "echo Ambi::Default"
[feature.test.tasks]
test = "echo Test"
# ambi = "echo Ambi::Test"

[feature.dev.tasks]
dev = "echo Dev"
# ambi = "echo Ambi::Dev"

[environments]
default = ["test", "dev"]
test = ["test"]
dev = ["dev"]

I do understand that there is a difference since in the first case tasks are overwritten in other features. However this seems very nuanced and hard to grasp. Wouldn't it be better to simplify it so that:

If there are multiple possible environments to run a task in and one of them is the default environment, run the task automatically inside the default environment.

Let me know what you think

dennis-wey avatar Aug 09 '24 11:08 dennis-wey