fix: ensure .env.local and .env.development.local override .env in CLI#3112
fix: ensure .env.local and .env.development.local override .env in CLI#3112deepshekhardas wants to merge 2 commits intotriggerdotdev:mainfrom
Conversation
Corrected the order of env file loading to follow standard precedence conventions where local and environment-specific files override the base .env file.
🦋 Changeset detectedLatest 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 |
|
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. |
There was a problem hiding this comment.
🚩 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)
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Having this issue also. I think this PR just needs a slight change, it's not the order of the .env files. Line 20:
It can be given override: true, by default that is set to false. When false, the first file wins. |
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