diff --git a/packages/process-utils/src/index.ts b/packages/process-utils/src/index.ts index 8b8568b47..ce07ccaf0 100644 --- a/packages/process-utils/src/index.ts +++ b/packages/process-utils/src/index.ts @@ -177,6 +177,8 @@ export function resolveContainedPath( return resolvedCandidatePath; } +const VOLTA_RECURSION_GUARD_ENV = "_VOLTA_TOOL_RECURSION"; + /** * The one answer to "what does a bb-spawned child process inherit": the * parent's env minus bb runtime-owned variables (`BB_*`) and `NODE_ENV`, @@ -194,6 +196,14 @@ export function sanitizeInheritedChildProcessEnv( if (key === "NODE_ENV" || key.startsWith("BB_")) { continue; } + // Volta's re-entrancy guard. A Volta package shim sets it on the process + // it launches (bb-app), and Volta's own `node`/`npm`/`npx` shims treat its + // presence as "do not re-evaluate the platform" and pass through to a + // system Node instead. bb children are new contexts, exactly like + // `volta run`, which removes the same variable before spawning. + if (key === VOLTA_RECURSION_GUARD_ENV) { + continue; + } sanitizedEnv[key] = value; } if (args.shellPath !== undefined) {