docs: `dev --env-file` help/docs say it does not reach tasks, but it does

Ouverte
#4,425 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

  • #4473 par @RealBhupesh — fermée sans fusion
  • #4478 par @BILLKISHORE — fermée sans fusion

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
typescript
Domaine
cli, documentation

Piste de recherche

Start by reading dev/devSupervisor.ts and the resolveLocalEnvVars → resolveDotEnvVars path mentioned in the issue, then compare it with the dev/deploy/preview CLI help and the three named docs pages. Reproduce with a task reading process.env.PROBE and trigger dev --env-file custom.env; done means the documented contract and actual behavior agree. Two pull requests have already been linked, so check their discussions before starting.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Provide environment information

trigger.dev 4.5.0 (also verified 4.5.9)

Describe the bug

The --env-file option is documented — in the CLI --help for dev/deploy/preview and in the docs pages (cli-dev-commands, cli-deploy-commands, cli-preview-archive) — as:

Load environment variables from a file. This will only hydrate the process.env of the CLI process, not the tasks.

But in dev, the file is passed through to the tasks. DevSupervisor.#getEnvVars() (dev/devSupervisor.ts) builds the run environment from resolveLocalEnvVars(this.options.args.envFile, …):

async #getEnvVars() {
    const environmentVariablesResponse = await this.options.client.getEnvironmentVariables(...);
    return {
        ...resolveLocalEnvVars(this.options.args.envFile, environmentVariablesResponse.success ? ... : {}),
        NODE_ENV: "development",
        ...
    };
}

and resolveLocalEnvVars(envFile, …) → resolveDotEnvVars(undefined, envFile) reads exactly that file and includes it in what the task receives via process.env.

To reproduce
  1. echo "PROBE=from-file" > custom.env
  2. trigger dev --env-file custom.env
  3. In a task: process.env.PROBE
  4. It is from-file — the task does see the --env-file value.

Expected per the docs: the task should NOT see it (docs say the flag only affects the CLI process).

Which is correct?

The behavior (file reaches tasks) is arguably the more useful one — passing --env-file /path/to/empty is a clean way to make the CLI read no ambient .env* files and rely solely on the injected process.env. But the docs and --help text state the opposite, so please either:

  • fix the docs/--help to say --env-file values are included in the task environment, or
  • if the documented behavior is the intended contract, fix dev to not pass envFile into resolveLocalEnvVars.

Either way the code and the docs currently disagree, which makes --env-file hard to reason about.

Additional information

Related: #2999 (the .env vs .env.local precedence bug in the same resolveDotEnvVars path).

Langage dominant
TypeScript
Étoiles
16.5k
Forks
1.5k
Merge moyen
1 j 15 h
PR mergées (30 j)
17

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de triggerdotdev/trigger.dev

Toutes les issues de triggerdotdev/trigger.dev

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.