Closed theunrepentantgeek closed 2 years ago
I've also just run into this while setting up common tasks to share amongst all projects.
Tried to work around it by specifying a WORKSPACE_ROOT
var, however there's no templating available for the taskfile parameter either (we need to be able to execute task
from the workspace root and from project directories).
Thanks for flagging + preparing a patch, hopefully it gets released soon
When resolving taskfile imports using relative paths, the base directory used to resolve the path isn't consistent, resulting in attempts to read the taskfile from the wrong folder.
Example
Directory structure:
/path/to/project/Taskfile.yaml
# top level/path/to/project/alpha/Taskfile.yaml
first subfolder/path/to/project/common/Taskfile.yaml
second subfolder, a sibling ofalpha
Expected behaviour
Relative path references to included Taskfiles resolved from the directory containing the including taskfile.
/path/to/project/alpha/Taskfile.yaml
the reference to../common/Taskfile.yaml
should resolve as/path/to/project/common/Taskfile.yaml
/path/to/project/Taskfile.yaml
the reference to./alpha/Taskfile.yaml
should resolve as/path/to/project/alpha/Taskfile.yaml
, and the reference to./common/Taskfile.yaml
should resolve as/path/to/project/common/Taskfile.yaml
Actual behaviour
The path reference to
../common/Taskfile.yaml
from/path/to/project/alpha/Taskfile.yaml
is resolved using the folder/path/to/project/
, resulting in the path/path/to/common/Taskfile.yaml
which isn't found.Analysis
The function
Taskfile()
fromtaskfile/read/taskfile.go
reads in the hierarchy of includes, merging included taskfiles in as it goes.When reading
/path/to/project/alpha/Taskfile.yaml
the inclusion of../common/Taskfile.yaml
is correctly resolved to/path/to/project/common/Taskfile.yaml
and the tasks are read in.Everything from
/path/to/project/alpha/Taskfile.yaml
is then merged into root taskfile found in/path/to/project/Taskfile.yaml
, including the nested include of../common/Taskfile.yaml
.This is then processed a second time, resolving to
/path/to/common/Taskfile.yaml
, triggering an error.