Skip to content

bug: .env.local doesn't override .env values in dev command #2999

@isshaddad

Description

@isshaddad

Provide environment information

v4.3.2

Describe the bug

When running trigger dev, .env.local should override values from .env, but it doesn't. The .env values are used instead

Reproduction repo

n/a

To reproduce

To reproduce:

  1. Create .env with TEST_VAR=from-env
  2. Create .env.local with TEST_VAR=from-local
  3. Run npx trigger.dev dev
  4. In your task, check process.env.TEST_VAR
  5. It shows from-env instead of from-local

Expected: .env.local should override .env, so TEST_VAR should be from-local.

Additional information

The issue is most probably in packages/cli-v3/src/utilities/dotEnv.ts. The code passes an array to dotenv.config({ path: envFilePath }), but dotenv.config() only accepts a string path, not an array. This means only the first file (.env) is loaded.

Potential fix:
Loop through each file in ENVVAR_FILES and call dotenv.config() for each one in order, so later files override earlier ones

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions