Skip to content

.CLI_ARGS is empty when dotenv is configured at the root level #2762

@pawciobiel

Description

@pawciobiel

Description

When dotenv is configured at the root level of a Taskfile, {{.CLI_ARGS}} is always empty even when arguments are passed after -- on the command line.

Reproduction:

.env (any valid env file):

FOO=bar

Taskfile.yml:

  version: '3'
  dotenv: ['.env']
  tasks:
    test:
      cmds:
        - echo "args={{.CLI_ARGS}}"

Run:
go-task test -- hello world

Expected output:
args=hello world

Actual output:
args=

Notes"

  • Removing dotenv from the Taskfile makes {{.CLI_ARGS}} work correctly
  • $CLI_ARGS as a shell variable is also empty — it is not exported to the environment
  • Tested on go-task version 3.49.0 on Linux

Workaround:

Pass arguments as prefixed environment variables instead:

EMAIL=foo@bar.com go-task mytask

Version

3.49.0

Operating system

Alpine Linux 3.24.0_alpha20260127 with kernel 6.18.2

Experiments Enabled

No response

Example Taskfile

version: '3'
dotenv: ['.env']
tasks:
  test:
    cmds:
      - echo "args={{.CLI_ARGS}}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions