T
Task3y ago
Rots

Dependencies not being run

I think I've found a bug....
version: '3'

tasks:
hello:
cmd: echo 'Hello World from Task!'
deps:
- there
hello2:
cmds: [echo 'Hello World from Task!']
deps:
- there
there: echo "there" && sleep 5 && echo "done"
version: '3'

tasks:
hello:
cmd: echo 'Hello World from Task!'
deps:
- there
hello2:
cmds: [echo 'Hello World from Task!']
deps:
- there
there: echo "there" && sleep 5 && echo "done"
If I now run:
$ task hello
task: [hello] echo 'Hello World from Task!'
Hello World from Task!
$ task hello2
task: [there] echo "there" && sleep 5 && echo "done"
there
done
task: [hello2] echo 'Hello World from Task!'
Hello World from Task!
$ task hello
task: [hello] echo 'Hello World from Task!'
Hello World from Task!
$ task hello2
task: [there] echo "there" && sleep 5 && echo "done"
there
done
task: [hello2] echo 'Hello World from Task!'
Hello World from Task!
the hello task doesn't run the dependencies, hello2 is fine Is this expected or am I doing something wrong?
5 Replies
pd93
pd933y ago
That's an interesting one. I think Task is parsing something that it shouldn't be here. You can make this work by changing your Taskfile to this:
version: '3'

tasks:
hello:
cmds: [echo 'Hello World from Task!']
deps:
- there
hello2:
cmds: [echo 'Hello World from Task!']
deps:
- there
there: echo "there" && sleep 5 && echo "done"
version: '3'

tasks:
hello:
cmds: [echo 'Hello World from Task!']
deps:
- there
hello2:
cmds: [echo 'Hello World from Task!']
deps:
- there
there: echo "there" && sleep 5 && echo "done"
I've just replaced cmd with cmds and put brackets [] around the command to change it to a list. The cmd keyword is only meant for a command in a list. e.g:
tasks:
hello:
cmds:
- cmd: echo 'Hello World from Task!'
silent: true
tasks:
hello:
cmds:
- cmd: echo 'Hello World from Task!'
silent: true
This is so you can add other keys to the cmd such as slient (like above)
Rots
RotsOP3y ago
Yes, that's why I'm thinking this is a bug why would cmd: be different from cmds:? apart from the obvious list vs single command
pd93
pd933y ago
cmd by design is only supposed to work as an object key in a list of cmds. There is currently no functionality that lets you specify cmd at the top level of a task. I agree that this is a bug because Task should be erroring with the given Taskfile (since its not currently valid). If we wanted to support cmd at the top level, this would be a feature request @Rots Would you be willing to post this as an issue on GitHub so we can track it?
Rots
RotsOP3y ago
GitHub
cmd: accepted as task key · Issue #911 · go-task/task
As discussed in https://discord.com/channels/974121106208354339/1035111266005569567 With this input version: '3' tasks: hello-broken: cmd: echo 'Hello World from Task!&#...
pd93
pd933y ago
Thank you!

Did you find this page helpful?