Skip to content

Turborepo globalEnv has 250+ entries, effectively defeating build caching for most contributors #28633

@mahdirajaee

Description

@mahdirajaee

Description

turbo.json currently lists over 250 environment variables in globalEnv. In Turborepo, any variable in globalEnv is included in the hash for every single task. Changing any one of those 250+ variables — or simply having it undefined vs. defined — invalidates the entire cache across all packages.

Impact

For self-hosted operators and new contributors, turbo almost never achieves cache hits between runs because:

  • Their env differs from the last run (common in CI, after branch switches, or Docker restarts)
  • @calcom/web#build additionally re-declares 30+ of those same variables in its own env field, creating double-hashing
  • Secrets like STRIPE_PRIVATE_KEY, TWILIO_TOKEN, DAILY_API_KEY are in globalEnv but are unlikely to affect build output for most packages

The result: developers rebuild from scratch on nearly every run, making the monorepo DX significantly slower than it needs to be.

Proposed Fix

Audit the globalEnv list and move most entries to per-task env declarations. Only variables that genuinely affect all tasks should remain global:

  • NODE_ENV
  • CI
  • DATABASE_URL
  • A handful of others

Everything else should be scoped to the specific task/package that uses it. This is a straightforward but high-impact DX improvement.

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