Skip to content

Documentation: Clarify dotenv file precedence when multiple files are specified #2621

@boukeversteegh

Description

@boukeversteegh

Summary

The documentation does not clarify which dotenv file takes precedence when multiple files are specified in the dotenv array.

Current Documentation

The usage guide shows this example:

dotenv: ['.env', '{{.ENV}}/.env', '{{.HOME}}/.env']

But it doesn't specify whether the first or last file in the array takes precedence when the same variable appears in multiple files.

Observed Behavior (Task v3.44.1)

Through empirical testing, I found that the first file wins (first listed file takes precedence):

# Test setup
dotenv:
  - '.env.local'      # Contains: API_URL=http://local-override:9999
  - '.env'            # Contains: API_URL=http://localhost:5029

# Result: API_URL=http://local-override:9999 (first file wins)

When reversed:

dotenv:
  - '.env'            # Contains: API_URL=http://localhost:5029
  - '.env.local'      # Contains: API_URL=http://local-override:9999

# Result: API_URL=http://localhost:5029 (first file still wins)

Request

Please update the documentation to explicitly state the precedence order for multiple dotenv files. This is important for users who want to implement override patterns like:

dotenv:
  - '.env.{{.ENV}}.local'    # Local overrides (if first wins, put highest priority first)
  - '.env.{{.ENV}}'          # Environment config
  - '.env'                   # Base defaults

Environment

  • Task version: 3.44.1
  • OS: Windows (MINGW64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: docsChanges related to documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions