From a32c4e43b4183f09665e323302c505d5b4242a4f Mon Sep 17 00:00:00 2001 From: Richard Poelderl Date: Thu, 2 Apr 2026 16:43:42 +0200 Subject: [PATCH] Update Corepack prompt handling --- src/infra/update-global.test.ts | 15 +++++++++++++++ src/infra/update-global.ts | 12 +++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/infra/update-global.test.ts b/src/infra/update-global.test.ts index 92a83b09de6..92c86205e7d 100644 --- a/src/infra/update-global.test.ts +++ b/src/infra/update-global.test.ts @@ -11,6 +11,7 @@ import { cleanupGlobalRenameDirs, detectGlobalInstallManagerByPresence, detectGlobalInstallManagerForRoot, + createGlobalInstallEnv, globalInstallArgs, globalInstallFallbackArgs, isExplicitPackageInstallSpec, @@ -89,6 +90,20 @@ describe("update global helpers", () => { ).toBe("https://example.com/openclaw-main.tgz"); }); + it("defaults corepack download prompts off for global install env", async () => { + await expect(createGlobalInstallEnv({})).resolves.toMatchObject({ + COREPACK_ENABLE_DOWNLOAD_PROMPT: "0", + }); + + await expect( + createGlobalInstallEnv({ + COREPACK_ENABLE_DOWNLOAD_PROMPT: "1", + }), + ).resolves.toMatchObject({ + COREPACK_ENABLE_DOWNLOAD_PROMPT: "1", + }); + }); + it("classifies main and raw install specs separately from registry selectors", () => { expect(isMainPackageTarget("main")).toBe(true); expect(isMainPackageTarget(" MAIN ")).toBe(true); diff --git a/src/infra/update-global.ts b/src/infra/update-global.ts index ce2da669ab1..a7b1b7ac951 100644 --- a/src/infra/update-global.ts +++ b/src/infra/update-global.ts @@ -29,6 +29,7 @@ const PRIMARY_PACKAGE_NAME = "openclaw"; const ALL_PACKAGE_NAMES = [PRIMARY_PACKAGE_NAME] as const; const GLOBAL_RENAME_PREFIX = "."; export const OPENCLAW_MAIN_PACKAGE_SPEC = "github:openclaw/openclaw#main"; +const COREPACK_ENABLE_DOWNLOAD_PROMPT_DEFAULT = "0"; const NPM_GLOBAL_INSTALL_QUIET_FLAGS = ["--no-fund", "--no-audit", "--loglevel=error"] as const; const NPM_GLOBAL_INSTALL_OMIT_OPTIONAL_FLAGS = [ "--omit=optional", @@ -140,6 +141,13 @@ function applyWindowsPackageInstallEnv(env: Record) { env.NODE_LLAMA_CPP_SKIP_DOWNLOAD = "1"; } +function applyCorepackDownloadPromptEnv(env: Record) { + const current = env.COREPACK_ENABLE_DOWNLOAD_PROMPT?.trim(); + if (!current) { + env.COREPACK_ENABLE_DOWNLOAD_PROMPT = COREPACK_ENABLE_DOWNLOAD_PROMPT_DEFAULT; + } +} + export function resolveGlobalInstallSpec(params: { packageName: string; tag: string; @@ -165,9 +173,6 @@ export async function createGlobalInstallEnv( env?: NodeJS.ProcessEnv, ): Promise { const pathPrepend = await resolvePortableGitPathPrepend(env); - if (pathPrepend.length === 0 && process.platform !== "win32") { - return env; - } const merged = Object.fromEntries( Object.entries(env ?? process.env) .filter(([, value]) => value != null) @@ -175,6 +180,7 @@ export async function createGlobalInstallEnv( ) as Record; applyPathPrepend(merged, pathPrepend); applyWindowsPackageInstallEnv(merged); + applyCorepackDownloadPromptEnv(merged); return merged; }