Working directory of included taskfiles differs depending on called task's location
Given the following Taskfiles:
# test/Taskfile.yaml --- version: 3 includes: foo: taskfile: lib/foo.yaml dir: ./ tasks: pwd: cmds: - echo $PWD toplevel:foo-bar-pwd: cmds: - task: foo:bar:pwd
# test/lib/foo.yaml --- version: 3 includes: bar: taskfile: ./bar.yaml dir: ./ tasks: pwd: cmds: - echo $PWD foolevel:bar-pwd: cmds: - task: bar:root
# test/lib/bar.yaml --- version: 3 tasks: pwd: cmds: - echo $PWD
We get the following behaviour when calling the above tasks:
🐟 ❯ task pwd task: [pwd] echo $PWD /tmp/test 🐟 ❯ task foo:pwd task: [foo:pwd] echo $PWD /tmp/test took 10s 🐟 ❯ task foo:foolevel:bar-pwd task: [foo:bar:pwd] echo $PWD /tmp/test/lib 🐟 ❯ task foo:bar:pwd task: [foo:bar:pwd] echo $PWD /tmp/test/lib
IMO, this is unexpected behaviour and a bug - as I'm calling all tasks from test/Taskfile.yaml, which specifically declares the exec directory should be ./ for the included taskfiles.
In otherwords, the correct behaviour should be as follows if running foo.yaml in the lib directory:
🐟 ❯ task -t foo.yaml pwd task: [pwd] echo $PWD /tmp/test/lib 🐟 ❯ task -t foo.yaml foolevel:bar-pwd task: [bar:pwd] echo $PWD /tmp/test/lib 🐟 ❯ task -t foo.yaml bar:pwd task: [bar:pwd] echo $PWD /tmp/test/lib
tl;dr: It looks like the value of dir is dependent on the location of task being called within the taskfiles includes tree, instead of being correctly merged/updated with the parent taskfile's dir when recursing into the included files.
Task Version
🐟 ❯ task --version Task version: v3.17.0 (h1:tDkE4X8VUUSNzFMTQNuEEhR/3cfI9hILLuwm365sNCM=)