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

env and vars sections are evaluated without checking platforms #1273

Closed
JamieEdge opened this issue Jul 21, 2023 · 2 comments · Fixed by #1377
Closed

env and vars sections are evaluated without checking platforms #1273

JamieEdge opened this issue Jul 21, 2023 · 2 comments · Fixed by #1377

Comments

@JamieEdge
Copy link
Contributor

The env and vars sections of a task are always resolved, even if the the current platform is not listed in platforms.

This is reproducible using the following Taskfile.

version: 3

tasks:
  default:
    - task: windows
    - task: darwin

  windows:
    internal: true
    platforms:
      - windows
    env:
      EXAMPLE_ENV:
        sh: exit 1
    vars:
      EXAMPLE_VAR:
        sh: exit 2
    cmds:
      - echo Windows

  darwin:
    internal: true
    platforms:
      - darwin
    cmds:
      - echo Darwin

The issue is shown in the following output.

$ uname
Darwin
$ task
task: Failed to run task "default": task: Command "exit 2" failed: exit status 2

This is problematic when setting a value to the output of a platform-specific command (e.g. the output of mktemp, which is not available on Windows).

  • Task version: v3.27.1 (h1:cftsoOqUo7/pCdtO7fDa4HreXKDvbrRhfhhha8bH9xc=)
  • Operating system: macOS 13.4.1 (22F82)
  • Experiments enabled: None
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Jul 21, 2023
@JamieEdge
Copy link
Contributor Author

It's possible to workaround this issue by using the Go template engine (e.g. {{if eq OS "windows"}}command{{end}}).

@andreynering
Copy link
Member

Hi @JamieEdge,

Thanks for reporting. Fixed by #1377.

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

Successfully merging a pull request may close this issue.

3 participants