diff --git a/packages/env/src/server.ts b/packages/env/src/server.ts index d97bc1105..d0278b106 100644 --- a/packages/env/src/server.ts +++ b/packages/env/src/server.ts @@ -7,11 +7,11 @@ const workspaceRoot = findWorkspaceRoot(); if (workspaceRoot) { try { - // ponytail: native stand-in for dotenv. loadEnvFile throws when .env is absent - // (e.g. production with injected env), and existing process.env still wins — so just tolerate a miss. + // Native stand-in for dotenv: existing process.env still wins over file values. process.loadEnvFile(join(workspaceRoot, ".env")); - } catch { - // no .env file — rely on the ambient process environment + } catch (error) { + // A missing .env is expected (e.g. production with injected env); anything else is a real problem. + if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error; } }