Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globalPassThroughEnv and passThroughEnv don't get merged #9659

Open
anthonyshew opened this issue Dec 30, 2024 · 1 comment
Open

globalPassThroughEnv and passThroughEnv don't get merged #9659

anthonyshew opened this issue Dec 30, 2024 · 1 comment
Labels
kind: bug Something isn't working

Comments

@anthonyshew
Copy link
Contributor

anthonyshew commented Dec 30, 2024

(Using my Maintainer's Privilege™️ here to ignore the bug report template) 😄

@juliusmarminge found us a bug and I'm filing on his behalf. In the following two logs, you can see a difference in the printed output of NODE_ENV:

Notably, the cache hit comes from a run that happened on Vercel, where NODE_ENV is set. This isn't the case in a GitHub Action by default.

The expectation is that this globalPassThroughEnv can be overridden by a passThroughEnv in a Package Configuration.

Here's my reproduction repository. Summary of changes (starting with create-turbo) and how I'm reproducing locally:

  1. Put NODE_ENV into globalPassThroughEnv.
  2. Add the following snippet.
// ./packages/ui/turbo.json

{
  "extends": ["//"],
  "tasks": {
    "build": {
      "passThroughEnv": ["!NODE_ENV"],
    }
  }
}
  1. Add a ./packages/ui/run-this.js file with contents of console.log(process.env.NODE_ENV).
  2. Add a script of "build": "node run-this.js" to ./packages/ui/package.json.
  3. Put an export NODE_ENV=foo onto your shell.
  4. Run turbo build.

You'll get what I believe to be unexpected behavior: NODE_ENV printing foo from run-this.js.

I've tested some of my assumptions by messing with combinations of removing the globalPassThroughEnv, removing the Package Configuration's passThroughEnv, and placing a console.log(process.env.NODE_ENV) into the applications.

I'm thinking the bug here is that we don't merge globalPassThroughEnv with passThroughEnv. I can't find a codepath where this would happen (though I may be simply not be seeing it and there's something else at play that I haven't considered.)

@anthonyshew anthonyshew added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage and removed needs: triage New issues get this label. Remove it after triage labels Dec 30, 2024
@anthonyshew anthonyshew changed the title globalPassthroughEnv in root turbo.json and passThroughEnv in Package Configuration don't get merged. globalPassthroughEnv in root turbo.json and passThroughEnv in Package Configuration don't get merged Dec 30, 2024
@anthonyshew anthonyshew changed the title globalPassthroughEnv in root turbo.json and passThroughEnv in Package Configuration don't get merged globalPassThroughEnv in root turbo.json and passThroughEnv in Package Configuration don't get merged Dec 30, 2024
@anthonyshew anthonyshew changed the title globalPassThroughEnv in root turbo.json and passThroughEnv in Package Configuration don't get merged globalPassThroughEnv and passThroughEnv don't get merged Dec 30, 2024
@anthonyshew
Copy link
Contributor Author

anthonyshew commented Dec 30, 2024

Just realized the Package Configuration isn't needed to reproduce this behavior. A root turbo.json like this one reproduces.

{
  "globalPassThroughEnv": ["NODE_ENV"],
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "passThroughEnv": ["!NODE_ENV"],
      "inputs": ["$TURBO_DEFAULT$", ".env*"],
      "outputs": [".next/**", "!.next/cache/**"]
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant