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

Variables don't work at the beginning of a command #1417

Closed
fschoell opened this issue Nov 30, 2023 · 1 comment
Closed

Variables don't work at the beginning of a command #1417

fschoell opened this issue Nov 30, 2023 · 1 comment

Comments

@fschoell
Copy link

See this example Taskfile.yaml

version: '3'

vars:
  BUILD_FLAGS: 'GOOS=linux GOARCH=amd64'

tasks:
  build:
    cmds:
      - {{.BUILD_FLAGS}} go build

Result: Running task build fails with the following error:

task: Failed to parse Taskfile.yaml:
yaml: line 8: did not find expected '-' indicator

Expected behaviour: task build properly executing GOOS=linux GOARCH=amd64 go build

  • Task version: 3.32.0
  • Operating system: MacOS 14.1.1
  • Experiments enabled: no
@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Nov 30, 2023
@pd93
Copy link
Member

pd93 commented Nov 30, 2023

You need to quote your command string:

version: '3'

vars:
  BUILD_FLAGS: 'GOOS=linux GOARCH=amd64'

tasks:
  build:
    cmds:
      - '{{.BUILD_FLAGS}} go build'

Edit: Some extra info on this: https://stackoverflow.com/questions/19109912/yaml-do-i-need-quotes-for-strings-in-yaml

@pd93 pd93 closed this as completed Nov 30, 2023
@pd93 pd93 added the type: question Further information is requested. label Nov 30, 2023
@task-bot task-bot removed the state: needs triage Waiting to be triaged by a maintainer. label Nov 30, 2023
@pd93 pd93 removed the type: question Further information is requested. label Dec 15, 2024
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

No branches or pull requests

3 participants