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

requires not evaluated before dynamic variables #1970

Closed
hans-d opened this issue Dec 25, 2024 · 4 comments · Fixed by #1962
Closed

requires not evaluated before dynamic variables #1970

hans-d opened this issue Dec 25, 2024 · 4 comments · Fixed by #1962

Comments

@hans-d
Copy link

hans-d commented Dec 25, 2024

Description

Have a task that defines a `requires: { vars: [] }', and additionallyuse a dynamic variable.

The dynamic variables is resolved before the requires are checked.

Version

Task version: v3.40.1 (h1:Q/TjPh5SAI+XK2fBravDPZXNGm6mvnwrLJqCXfhZ3Wc=)

Operating system

Linux

Experiments Enabled

No response

Example Taskfile

version: '3'

tasks:
  test-ok:
    desc: Fails correctly
    requires:
      vars: [ FOO ]
    vars:
      BAR: '{{.FOO}}'
    cmds:
      - echo Got {{.FOO}} {{.BAR }}

  test-fail:
    desc: Should fail, but already executes sh `Command "echo '' && false" failed: exit status 1`
    requires:
      vars: [ FOO ]
    vars:
      BAR:
        sh: echo '{{.FOO}}' && false
    cmds:
      - echo Got {{.FOO}} {{.BAR }}
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Dec 25, 2024
@hans-d
Copy link
Author

hans-d commented Dec 27, 2024

related to the requires issue: #1950

@andreynering andreynering added area: requires and removed state: needs triage Waiting to be triaged by a maintainer. labels Dec 30, 2024
@andreynering
Copy link
Member

Hey @hans-d,

I tried your example Taskfile.yml, but it works fine for both tasks. I'm I missing anything?

➜  task git:(main) ✗ task test-ok
task: Task "test-ok" cancelled because it is missing required variables: FOO
➜  task git:(main) ✗ task test-fail
task: Task "test-fail" cancelled because it is missing required variables: FOO

@vmaerten
Copy link
Member

Hello !

@andreynering It has been fixed in #1962, but it's not released yet
@hans-d It'll be available in the next release

@pd93 pd93 linked a pull request Dec 30, 2024 that will close this issue
@andreynering
Copy link
Member

@vmaerten I didn't see that PR. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants