Skip to content

Dynamic variable resolution does not take into account current directory #2161

Open
@viktorasm

Description

@viktorasm

Description

when creating dynamic variables like files: sh: "find ." in multiple subfolders, they won't be correctly evaluated. Due to internal caching, only the first result will be used.

Posted PR with reproduction and fix: #2160

Sample input

Folder structure:

root/
├── Taskfile.yaml
└── sub1/
    ├── Taskfile.yaml
    └── a
└── sub2/
    ├── Taskfile.yaml
    └── b

Taskfile.yml

version: '3'

run: when_changed
silent: true
output: prefixed

includes:
  s1:
    taskfile: sub1
    dir: sub1
  s2:
    taskfile: sub2
    dir: sub2

tasks:
  all:
    deps:
      - s1:all
      - s2:all

sub1/Taskfile.yaml, sub2/Taskfile.yaml:

version: '3'

vars:
  files:
    sh: "find ."

tasks:
  all:
    cmds:
      - cmd: 'echo  "{{.files}}"'

Actual output:

$ task all
[s2:all] .
[s2:all] ./Taskfile.yml
[s2:all] ./b
[s1:all] .
[s1:all] ./Taskfile.yml
[s1:all] ./b

Note how "s1" lists file "b", which is incorrect.

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