Skip to content

flatten include default shell working directory is wrong #2290

@gergely-pepper

Description

@gergely-pepper

Description

Minimal reproducible demo:
Taskfile.yml:

version: '3'

includes:
  backend:
    taskfile: taskfiles/backend.yml
    flatten: true

taskfiles/backend.yml:

version: '3'

includes:
  common:
    taskfile: ./common.yml
    flatten: true

tasks:
  echo-pwd:
    desc: Prints current working directory and list of files.
    cmds:
      - echo {{.PWD}} && ls -l
      - task: echo-pwd2

taskfiles/common.yml:

version: '3'

tasks:
  echo-pwd2:
    desc: Prints current working directory and list of files.
    cmds:
      - echo {{.PWD}} && ls -l

Output:

> task echo-pwd
task: [echo-pwd] echo /tmp/task-include-dir && ls -l
/tmp/task-include-dir
total 8
-rw-r--r--@ 1 panda  staff   89 Jún  9 11:57 Taskfile.yml
drwxr-xr-x  4 panda  staff  128 Jún  9 11:58 taskfiles
task: [echo-pwd2] echo /tmp/task-include-dir && ls -l
/tmp/task-include-dir
total 16
-rw-r--r--@ 1 panda  staff  226 Jún  9 11:58 backend.yml
-rw-r--r--@ 1 panda  staff  137 Jún  9 11:58 common.yml

It seems that {{.PWD}} correctly contains /tmp/task-include-dir, but the shell PWD is actually the taskfiles subdirectory. The correct output should look like

> task echo-pwd
task: [echo-pwd] echo /tmp/task-include-dir && ls -l
/tmp/task-include-dir
total 8
-rw-r--r--@ 1 panda  staff   89 Jún  9 11:57 Taskfile.yml
drwxr-xr-x  4 panda  staff  128 Jún  9 11:58 taskfiles
task: [echo-pwd2] echo /tmp/task-include-dir && ls -l
/tmp/task-include-dir
total 8
-rw-r--r--@ 1 panda  staff   89 Jún  9 11:57 Taskfile.yml
drwxr-xr-x  4 panda  staff  128 Jún  9 11:58 taskfiles

Version

3.43.3

Operating system

MacOS M1 Sequoia 15.5

Experiments Enabled

No response

Example Taskfile

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