Skip to content

Comments

fix: ensure .env.local and .env.development.local override .env in CLI#3112

Closed
deepshekhardas wants to merge 2 commits intotriggerdotdev:mainfrom
deepshekhardas:fix/env-loading-precedence
Closed

fix: ensure .env.local and .env.development.local override .env in CLI#3112
deepshekhardas wants to merge 2 commits intotriggerdotdev:mainfrom
deepshekhardas:fix/env-loading-precedence

Conversation

@deepshekhardas
Copy link

This PR fixes the environment variable loading order in the CLI to follow standard precedence conventions.

Previously, .env was being loaded in a way that might not allow local overrides to consistently take precedence depending on how dotenv.config handles duplicates in the path array. By moving .env to the end of the ENVVAR_FILES list, we ensure that local and environment-specific files are preferred.

Fixes #2999

deepshekhardas added 2 commits February 23, 2026 14:57
Corrected the order of env file loading to follow standard precedence conventions where local and environment-specific files override the base .env file.
@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 8c6dc85

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

Hi @deepshekhardas, thanks for your interest in contributing!

This project requires that pull request authors are vouched, and you are not in the list of vouched users.

This PR will be closed automatically. See https://github.com/triggerdotdev/trigger.dev/blob/main/CONTRIBUTING.md for more details.

@github-actions github-actions bot closed this Feb 23, 2026
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 Pre-existing dead code: TRIGGER_API_URL is set then immediately deleted

On line 25, env.TRIGGER_API_URL && (result.TRIGGER_API_URL = env.TRIGGER_API_URL) conditionally assigns the system env value into result. But on line 28, delete result.TRIGGER_API_URL unconditionally removes it. The assignment on line 25 is therefore always a no-op — whatever value is written is immediately erased.

This looks like a remnant of an earlier version of this function where the delete may not have existed, or the intent was to only delete the dotenv-sourced value (not the system env value). Either way, line 25 currently does nothing and should likely be removed for clarity, or the deletion logic should be adjusted if the system env value was meant to survive.

(Refers to lines 25-28)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@ArronKing
Copy link

Having this issue also.

I think this PR just needs a slight change, it's not the order of the .env files. Line 20:

dotenv.config

It can be given override: true, by default that is set to false. When false, the first file wins.

https://www.npmjs.com/package/dotenv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants