Skip to content

Circular includes cause incorrect task execution directory #1860

@manzamor-cs

Description

@manzamor-cs

In my project I'd like to have a file with shared tasks (Tasklib.yaml) included in the Taskfiles of subdirectories. I then want to include the subdirectory Taskfiles in my root directory Taskfile. The project structure looks like this:

.
├── subdir/
│   └── Taskfile.yaml
├── Taskfile.yaml
└── Tasklib.yaml

The root Taskfile.yaml looks like this:

version: '3'

includes:
  subdir:
    taskfile: subdir/Taskfile.yaml
  shared:
    taskfile: Tasklib.yaml

tasks:
  test: ls ; echo

The shared tasks Tasklib.yaml looks like this:

version: '3'

tasks:
  shared-test: ls ; echo

The subdirectory Taskfile.yaml looks like this:

version: '3'

includes:
  shared:
    taskfile: ../Tasklib.yaml
    flatten: true

tasks:
  subdir-test: ls ; echo

When I run task -a, this is the output:

❯ task -a                                                                                                                               
task: Available tasks for this project:
* test:                     
* shared:shared-test:       
* subdir:shared-test:       
* subdir:subdir-test:    

When I run all of the tasks, subdir:shared-test gives a different output, despite running from the same folder and not having the dir property set in the include.

task test ; task shared:shared-test ; task subdir:shared-test ; task subdir:subdir-test                                        
task: [test] ls ; echo
Taskfile.yaml   Tasklib.yaml    subdir

task: [shared:shared-test] ls ; echo
Taskfile.yaml   Tasklib.yaml    subdir

task: [subdir:shared-test] ls ; echo
Taskfile.yaml

task: [subdir:subdir-test] ls ; echo
Taskfile.yaml   Tasklib.yaml    subdir

I'd expect these all to have the same output based on what the documentation states about the execution directory, but I guess having this circular include leads to a different output for the shared task when included from the subdirectory's Taskfile. Sorry if this has been posted before, but I couldn't identify an issue with this exact problem laid out. Please let me know if this is intended or not. Thank you!


  • Task version: 3.39.2
  • Operating system: macOS Sonoma 14.6.1
  • Experiments enabled: false

Metadata

Metadata

Assignees

No one assigned

    Labels

    state: needs triageWaiting to be triaged by a maintainer.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions