prefix-dev / pixi

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

Nested tasks #1572

Open apple-phi opened 1 month ago

apple-phi commented 1 month ago

Checks

Reproducible example

# pixi.toml
[project]
name = "cv"
channels = ["conda-forge"]
platforms = ["win-64"]

[tasks]
build = {cmd = ["tectonic", "-X", "build"]}
b = {depends-on = ["build"]}
watch = {cmd = ["tectonic", "-X", "watch"]}
pdfcpu = {cmd = ["go", "run", "github.com/pdfcpu/pdfcpu/cmd/pdfcpu@latest"]}
appendCL = {cmd = ["pdfcpu", "merge", "build/merged.pdf", "build/cv/cv.pdf"]}

[dependencies]
tectonic = ">=0.15.0,<0.16"
go = ">=1.22.5,<1.23"
> pixi run appendCL build/akuna/akuna.pdf
Pixi task (appendCL in default): pdfcpu merge build/merged.pdf build/cv/cv.pdf build/akuna/akuna.pdf
pdfcpu: command not found

Available tasks:
        appendCL
        b
        build
        pdfcpu
        watch

Issue description

It appears that pixi tasks can't run other pixi tasks outside of depends-on (e.g. to run them with arguments), which I didn't notice in the documentation. Also, the error message is misleading, since it clearly lists the desired subtask pdfcpu in the available tasks after saying it can't be found.

So, either this is a bug in the error message, or this is an undocumented missing feature.

Expected behavior

Either pixi tasks should run other pixi tasks with supplied arguments, or the error message shouldn't state the contradiction that it can't find the task but lists it anyway.

ruben-arts commented 1 month ago

We indeed don't parse the task itself as a pixi run command. This is where the depends-on comes in.

There is a feature request for arguments: #957

But the idea of simply allowing to run a task from a task is a good idea!

apple-phi commented 1 month ago

But the idea of simply allowing to run a task from a task is a good idea!

Any chance you could give some pointers on where in the codebase to look please so that I or someone else interested can figure out an implementation and make a PR?