Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Included variables using common names are getting overriden #1643

Closed
nick-jones opened this issue May 9, 2024 · 3 comments · Fixed by #1649
Closed

Included variables using common names are getting overriden #1643

nick-jones opened this issue May 9, 2024 · 3 comments · Fixed by #1649
Labels
area: variables Changes related to variables. type: bug Something not working as intended.

Comments

@nick-jones
Copy link

nick-jones commented May 9, 2024

Apologies if this is an intentional change, or we were previously relying on functionality in a way we shouldn't have been.

Before v3.37.0, it was possible to have 2 Taskfile includes declare variables with the same name, as these were treated in isolation. As a very basic example:

./Taskfile.yaml

version: "3"

includes:
  foo:
    taskfile: ./foo/Taskfile.yaml
  bar:
    taskfile: ./bar/Taskfile.yaml

tasks:
  stub:
    cmds:
      - echo 0

./foo/Taskfile.yaml

version: "3"

vars:
  DIR: foo

tasks:
  pwd:
    dir: ./{{ .DIR }}
    cmds:
      - echo "{{ .DIR }}"
      - pwd

./bar/Taskfile.yaml

version: "3"

vars:
  DIR: bar

tasks:
  pwd:
    dir: ./{{ .DIR }}
    cmds:
      - echo "{{ .DIR }}"
      - pwd

So both includes declare a DIR variable. Previously these would not conflict with each other, at least from my observations:

<snip>
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo

However, as of the latest release, I see that DIR is sometimes confused with the value declared in the other include:

<snip>
/Users/nj/scratch/task/bar
$ task foo:pwd
task: [foo:pwd] echo "bar"
bar
task: [foo:pwd] pwd
/Users/nj/scratch/task/bar
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo
$ task foo:pwd
task: [foo:pwd] echo "bar"
bar
task: [foo:pwd] pwd
/Users/nj/scratch/task/bar

I'm not expecting bar to be referenced here at all.


  • Task version: v3.37.1
  • Operating system: OSX
  • Experiments enabled: none
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label May 9, 2024
@csmith-n1
Copy link

Apologies if this is an intentional change, or we were previously relying on functionality in a way we shouldn't have been.

Before v3.37.0, it was possible to have 2 Taskfile includes declare variables with the same name, as these were treated in isolation. As a very basic example:

./Taskfile.yaml

version: "3"

includes:
  foo:
    taskfile: ./foo/Taskfile.yaml
  bar:
    taskfile: ./bar/Taskfile.yaml

tasks:
  stub:
    cmds:
      - echo 0

./foo/Taskfile.yaml

version: "3"

vars:
  DIR: foo

tasks:
  pwd:
    dir: ./{{ .DIR }}
    cmds:
      - echo "{{ .DIR }}"
      - pwd

./bar/Taskfile.yaml

version: "3"

vars:
  DIR: bar

tasks:
  pwd:
    dir: ./{{ .DIR }}
    cmds:
      - echo "{{ .DIR }}"
      - pwd

So both includes declare a DIR variable. Previously these would not conflict with each other, at least from my observations:

<snip>
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo

However, as of the latest release, I see that DIR is sometimes confused with the value declared in the other include:

<snip>
/Users/nj/scratch/task/bar
$ task foo:pwd
task: [foo:pwd] echo "bar"
bar
task: [foo:pwd] pwd
/Users/nj/scratch/task/bar
$ task foo:pwd
task: [foo:pwd] echo "foo"
foo
task: [foo:pwd] pwd
/Users/nj/scratch/task/foo
$ task foo:pwd
task: [foo:pwd] echo "bar"
bar
task: [foo:pwd] pwd
/Users/nj/scratch/task/bar

I'm not expecting bar to be referenced here at all.

  • Task version: v3.37.1
  • Operating system: OSX
  • Experiments enabled: none

Yes, discovered the same issue. Currently pinning previous version. 😢

@Jayden-58
Copy link

I am experiencing this as well. Currently pinning to v3.36.0 as that was the pervious version to work for me. thanks @csmith-n1!

@pd93 pd93 added type: bug Something not working as intended. area: variables Changes related to variables. and removed state: needs triage Waiting to be triaged by a maintainer. labels May 10, 2024
@pd93
Copy link
Member

pd93 commented May 10, 2024

I've created a fix for this in #1649.

@nick-jones, @csmith-n1, @Jayden-58 and any others following this, if you're running go, you can test the fix out by installing Task with:

go install github.com/go-task/task/v3/cmd/task@37f32cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Changes related to variables. type: bug Something not working as intended.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants