@devries-cameron20 / t3code-1 / commits / 528687d226
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(acp-registry): inherited NPM_CONFIG_PREFIX no longer overrides the managed npm prefix on Windows (#38839)

Julius Marminge committed Nov 18, 2026 at 19:09 UTC 528687d2260ca0c132c6d634bcb15fc94c4604c6
2 files changed +62 -1
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+50
@@ -561,6 +561,56 @@ describe("AcpRegistrySupport", () => {
561 );
562 });
563
564 + it.effect("gives Windows npm commands only the managed prefix spelling", () => {
565 + const agent = makeAgent({ npx: { package: "@example/acp@1.2.3" } });
566 + return Effect.gen(function* () {
567 + const fileSystem = yield* FileSystem.FileSystem;
568 + const cacheDir = yield* fileSystem.makeTempDirectoryScoped({
569 + prefix: "t3-acp-registry-windows-npm-prefix-",
570 + });
571 + const toolchain = yield* makeFakeNpmToolchain(cacheDir);
572 + const environment = { ...toolchain.environment, NPM_CONFIG_PREFIX: "C:\\inherited-npm" };
573 + const realSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
574 + const npmEnvironments: Array<Record<string, unknown>> = [];
575 + const resolver = yield* AcpRegistrySupport.makeAcpRegistryCatalog({
576 + cacheDir,
577 + toolsDir: `${cacheDir}/tools`,
578 + registryUrl,
579 + }).pipe(
580 + Effect.provideService(HostProcess.Environment, environment),
581 + Effect.provideService(HostProcess.Platform, "win32"),
582 + Effect.provideService(SpawnExecutableResolution, (command) =>
583 + command === "npm" ? toolchain.npmPath : undefined,
584 + ),
585 + Effect.provideService(
586 + ChildProcessSpawner.ChildProcessSpawner,
587 + ChildProcessSpawner.make((command) => {
588 + if (command._tag === "StandardCommand" && command.command === toolchain.npmPath) {
589 + npmEnvironments.push({ ...command.options.env });
590 + }
591 + return realSpawner.spawn(command);
592 + }),
593 + ),
594 + );
595 +
596 + yield* resolver.resolve(settings(), "C:\\workspace", environment).pipe(Effect.ignore);
597 +
598 + expect(npmEnvironments.length).toBeGreaterThan(0);
599 + for (const env of npmEnvironments) {
600 + expect(Object.keys(env).filter((key) => key.toLowerCase() === "npm_config_prefix")).toEqual(
601 + ["npm_config_prefix"],
602 + );
603 + }
604 + }).pipe(
605 + Effect.scoped,
606 + Effect.provide(
607 + layerResolver((request) =>
608 + Effect.succeed(HttpClientResponse.fromWeb(request, new Response(makeRegistry(agent)))),
609 + ),
610 + ),
611 + );
612 + });
613 +
614 it.effect("keeps only the end of a failed install's output in its error", () => {
615 const agent = makeAgent({ npx: { package: "@example/acp@1.2.3" } });
616 return Effect.gen(function* () {
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+12 -1
@@ -312,6 +312,17 @@ function readEnvironmentPath(
312 );
313 }
314
315 +// Windows env keys are case-insensitive, and an inherited NPM_CONFIG_PREFIX would win over ours.
316 +function withoutNpmPrefix(
317 + environment: NodeJS.ProcessEnv,
318 + platform: NodeJS.Platform,
319 +): NodeJS.ProcessEnv {
320 + if (platform !== "win32") return environment;
321 + return Object.fromEntries(
322 + Object.entries(environment).filter(([key]) => key.toLowerCase() !== "npm_config_prefix"),
323 + );
324 +}
325 +
326 function withPreferredPath(
327 environment: NodeJS.ProcessEnv,
328 directory: string,
@@ -1250,7 +1261,7 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1261 );
1262 const packageEnvironment =
1263 distribution === "npx"
1253 - ? { ...environment, npm_config_prefix: packageRoot }
1264 + ? { ...withoutNpmPrefix(environment, platform), npm_config_prefix: packageRoot }
1265 : {
1266 ...environment,
1267 UV_TOOL_DIR: packageRoot,