From d84ce5e419b4acaabf30d8e6685f663df760ac0b Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 28 Apr 2026 21:39:03 +0100 Subject: [PATCH] fix(update): disable compile cache for post-update commands --- src/cli/update-cli.test.ts | 1 + src/cli/update-cli/update-command.ts | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/cli/update-cli.test.ts b/src/cli/update-cli.test.ts index 21ead0de744..04a8f8aecc9 100644 --- a/src/cli/update-cli.test.ts +++ b/src/cli/update-cli.test.ts @@ -591,6 +591,7 @@ describe("update-cli", () => { expect.objectContaining({ stdio: "inherit", env: expect.objectContaining({ + NODE_DISABLE_COMPILE_CACHE: "1", OPENCLAW_UPDATE_POST_CORE: "1", OPENCLAW_UPDATE_POST_CORE_CHANNEL: "dev", }), diff --git a/src/cli/update-cli/update-command.ts b/src/cli/update-cli/update-command.ts index 57a2342f066..7ced0ad50e8 100644 --- a/src/cli/update-cli/update-command.ts +++ b/src/cli/update-cli/update-command.ts @@ -302,6 +302,20 @@ function resolveServiceRefreshEnv( return resolvedEnv; } +function disableUpdatedPackageCompileCacheEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv { + return { + ...env, + NODE_DISABLE_COMPILE_CACHE: "1", + }; +} + +function resolveUpdatedInstallCommandEnv( + env: NodeJS.ProcessEnv, + invocationCwd?: string, +): NodeJS.ProcessEnv { + return disableUpdatedPackageCompileCacheEnv(resolveServiceRefreshEnv(env, invocationCwd)); +} + type UpdateDryRunPreview = { dryRun: true; root: string; @@ -376,7 +390,7 @@ async function refreshGatewayServiceEnv(params: { if (entrypoint) { const res = await runCommandWithTimeout([resolveNodeRunner(), entrypoint, ...args], { cwd: params.result.root, - env: resolveServiceRefreshEnv(params.env ?? process.env, params.invocationCwd), + env: resolveUpdatedInstallCommandEnv(params.env ?? process.env, params.invocationCwd), timeoutMs: SERVICE_REFRESH_TIMEOUT_MS, }); if (res.code === 0) { @@ -415,7 +429,7 @@ async function runUpdatedInstallGatewayRestart(params: { } const res = await runCommandWithTimeout([resolveNodeRunner(), entrypoint, ...args], { cwd: params.result.root, - env: resolveServiceRefreshEnv(params.env ?? process.env, params.invocationCwd), + env: resolveUpdatedInstallCommandEnv(params.env ?? process.env, params.invocationCwd), timeoutMs: SERVICE_REFRESH_TIMEOUT_MS, }); if (res.code === 0) { @@ -553,7 +567,7 @@ async function runPackageInstallUpdate(params: { name: `${CLI_NAME} doctor`, argv: [resolveNodeRunner(), entryPath, "doctor", "--non-interactive", "--fix"], env: { - ...process.env, + ...disableUpdatedPackageCompileCacheEnv(process.env), OPENCLAW_UPDATE_IN_PROGRESS: "1", }, timeoutMs: params.timeoutMs, @@ -1140,7 +1154,7 @@ async function continuePostCoreUpdateInFreshProcess(params: { const child = spawn(resolveNodeRunner(), argv, { stdio: "inherit", env: { - ...process.env, + ...disableUpdatedPackageCompileCacheEnv(process.env), [POST_CORE_UPDATE_ENV]: "1", [POST_CORE_UPDATE_CHANNEL_ENV]: params.channel, ...(resultPath ? { [POST_CORE_UPDATE_RESULT_PATH_ENV]: resultPath } : {}),