Skip to content

Loosing variables in non deterministic way #2253

@joeblew999

Description

@joeblew999

I have seen this now for a few days, where when you run task it looses variables.

HTML_DEEP_WHICH is changing under my feet.

task --version
3.43.3

go version
go version go1.24.3 darwin/arm64

I get same issue on windows too btw.

HTML_DEEP_NAME=x.html  task

HTML_DEEP_PATH              /Users/apple/workspace/go/src/github.com/joeblew999/pb-stack/mod/gui-web-native/test
HTML_DEEP_NAME              x.html
HTML_DEEP_WHICH             /x.html

then run it again without changing anything:

HTML_DEEP_PATH              /Users/apple/workspace/go/src/github.com/joeblew999/pb-stack/mod/gui-web-native/test
HTML_DEEP_NAME              x.html
HTML_DEEP_WHICH             /Users/apple/workspace/go/src/github.com/joeblew999/pb-stack/mod/gui-web-native/test/x.html

Either I am doing something wrong ?? non best practice ?

Its simple to show the error:

run.env:

HTML_DEEP_PATH={{.PWD}}/test
HTML_DEEP_NAME=index.html
HTML_DEEP_WHICH={{.HTML_DEEP_PATH}}/{{.HTML_DEEP_NAME}}

taskfile.yml:

# yaml-language-server: $schema=https://taskfile.dev/schema.json

version: '3'

# MUST have this ONLY in root for env variables to work.
dotenv: ['run.env', '{{.ENV}}/.env', '{{.HOME}}/.env']


env:
  # this allow overriding from CLI.
  HTML_DEEP_NAME: '{{.HTML_DEEP_NAME | default "test.html" }}'

var:
  HTML_DEEP_PATH: '{{.HTML_DEEP_PATH | default "{{.PWD}}" }}'
  HTML_DEEP_WHICH: '{{.HTML_DEEP_PATH}}/{{.HTML_DEEP_NAME}}'
  

tasks:
  default:
    cmds:
      - echo ''
      - echo 'HTML_DEEP_PATH              {{shellQuote .HTML_DEEP_PATH}}'
      - echo 'HTML_DEEP_NAME              {{.HTML_DEEP_NAME}}'
      - echo 'HTML_DEEP_WHICH             {{shellQuote .HTML_DEEP_WHICH}}'
      - echo ''
    silent: true

  

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