Skip to content

Included taskfiles inherit parent taskfile directory instead of root taskfile directory #939

@pd93

Description

@pd93

Not sure if this is intended behaviour when double nesting included taskfiles or not. Example below:

Base Taskfile includes another Taskfile in the tasks subdirectory.

# Taskfile.yml
version: '3'

includes:
  included: ./tasks/included.yml

Included Taskfile includes a utility Taskfile using the new internal keyword. It then defines 2 tasks. One to print the current directory and one to call a task in the util Taskfile that also prints its current directory.

# tasks/included.yml
version: '3'

includes:
  util:
    taskfile: ./util.yml
    internal: true

tasks:
  pwd:
    cmds:
      - pwd

  util-pwd:
    cmds:
      - task: util:pwd
# tasks/util.yml
version: '3'

tasks:
  pwd:
    cmds:
      - pwd

Output:

❯ task included:pwd
task: [included:pwd] pwd
/abs/path/to/project

❯ task included:util-pwd
task: [included:util:pwd] pwd
/abs/path/to/project/tasks

The utility Taskfile is getting the working directory of the included Taskfile not the root Taskfile. I can work around this by doing something like this in the included Taskfile:

includes:
  util:
    taskfile: ./util.yml
    internal: true
    dir: ../            # <-- fixes problem

This isn't really a problem per se, but it wasn't what I was initially expecting and was wondering if this is the intended behaviour or not. Obviously, any change here would be a breaking one.

  • Task version: 3.18
  • Operating System: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions