Skip to content

Environment variables wrongly lead the precedence #2162

Open
@visko-sc

Description

@visko-sc

Description

Reproduction steps:
.env:
MY_VAR=dotenv

Command: MY_VAR=environment task example

Expected output: task_value

Actual output: environment

Reference to expected behavior: https://taskfile.dev/usage/#variables:~:text=Variables%20can%20be%20set%20in%20many%20places%20in%20a%20Taskfile.%20When%20executing%20templates%2C%20Task%20will%20look%20for%20variables%20in%20the%20order%20listed%20below%20(most%20important%20first)%3A

Variables can be set in many places in a Taskfile. When executing templates, Task will look for variables in the order listed below (most important first):

Variables declared in the task definition
Variables given while calling a task from another (See Calling another task above)
Variables of the included Taskfile (when the task is included)
Variables of the inclusion of the Taskfile (when the task is included)
Global variables (those declared in the vars: option in the Taskfile)
Environment variables

Version

Task version: 3.42.1 (Homebrew)

Operating system

MacOS 15.4 Sequoia (24E248)

Experiments Enabled

No response

Example Taskfile

version: '3'

env:
  MY_VAR: "global"

tasks:
  example:
    dotenv: [".env"]
    env:
      MY_VAR: "task_value"
    cmds:
      - echo "$MY_VAR"

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