@devries-cameron20 / t3code-1 / commits / 1a2983ff05
Fork 0

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

fix(provider-core): provider updates find npm on the provider's custom PATH (#27321)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

ash committed Nov 1, 2026 at 03:37 UTC 1a2983ff0592b396183adca94df22d599fad97c3
5 files changed +61 -22
apps/server/src/provider/providerMaintenanceRunner.test.ts
+28 -6
@@ -856,17 +856,31 @@ describe("providerMaintenanceRunner", () => {
856 ),
857 );
858
859 - it.effect("resolves npm to a .cmd shim and routes through the shell on win32", () => {
859 + it.effect("resolves npm to a .cmd shim from the provider's PATH on win32", () => {
860 const captured: Array<{
861 readonly command: string;
862 readonly args: ReadonlyArray<string>;
863 readonly shell: boolean | string | undefined;
864 + readonly env: NodeJS.ProcessEnv | undefined;
865 }> = [];
866 return Effect.gen(function* () {
867 const { registry } = yield* makeRegistry(baseProvider, {
868 installedVersionAfterUpdate: "1.0.0",
869 });
869 - const runner = yield* makeTestRunner(registry);
870 + const runner = yield* makeTestRunner({
871 + ...registry,
872 + getProviderMaintenanceCapabilitiesForInstance: () =>
873 + Effect.succeed(
874 + makeProviderMaintenanceCapabilities({
875 + provider: CODEX_DRIVER,
876 + packageName: "@openai/codex",
877 + updateExecutable: "npm",
878 + updateArgs: ["install", "-g", "@openai/codex@latest"],
879 + updateLockKey: "npm-global",
880 + env: { PATH: "C:\\fake\\npm" },
881 + }),
882 + ),
883 + });
884
885 const result = yield* runner.updateProvider(CODEX_DRIVER);
886
@@ -879,17 +893,21 @@ describe("providerMaintenanceRunner", () => {
893 );
894 assert.deepEqual(call.args, []);
895 assert.strictEqual(call.shell, true);
896 + assert.deepStrictEqual(call.env, { PATH: "C:\\fake\\npm" });
897 assert.strictEqual(result.providers[0]?.updateState?.status, "succeeded");
898 }).pipe(
899 Effect.provide(
900 Layer.mergeAll(
901 Layer.succeed(HostProcess.Platform, "win32"),
902 + // Only the provider's PATH has npm.
903 Layer.succeed(HostProcess.Environment, {
888 - PATH: "C:\\fake\\npm",
904 + PATH: "C:\\Windows\\System32",
905 PATHEXT: ".COM;.EXE;.BAT;.CMD",
906 }),
891 - Layer.succeed(SpawnExecutableResolution, (command) =>
892 - command === "npm" ? "C:\\fake\\npm\\npm.cmd" : undefined,
907 + Layer.succeed(SpawnExecutableResolution, (command, _platform, env) =>
908 + command === "npm" && env.PATH === "C:\\fake\\npm"
909 + ? "C:\\fake\\npm\\npm.cmd"
910 + : undefined,
911 ),
912 layerLatestVersionHttpClient("1.0.0"),
913 Layer.succeed(
@@ -898,12 +916,16 @@ describe("providerMaintenanceRunner", () => {
916 const childProcess = command as unknown as {
917 readonly command: string;
918 readonly args: ReadonlyArray<string>;
901 - readonly options: { readonly shell?: boolean | string | undefined };
919 + readonly options: {
920 + readonly shell?: boolean | string | undefined;
921 + readonly env?: NodeJS.ProcessEnv | undefined;
922 + };
923 };
924 captured.push({
925 command: childProcess.command,
926 args: childProcess.args,
927 shell: childProcess.options.shell,
928 + env: childProcess.options.env,
929 });
930 return Effect.succeed(mockHandle({ stdout: "updated" }));
931 }),
apps/server/src/provider/providerMaintenanceRunner.ts
+3 -2
@@ -98,13 +98,14 @@ const runProviderMaintenanceCommandWithSpawner = Effect.fn("ProviderMaintenanceR
98 }) {
99 const collectCommandResult = Effect.fn("ProviderMaintenanceRunner.collectCommandResult")(
100 function* () {
101 + const env = input.env ? { env: input.env, extendEnv: true } : {};
102 // Windows batch shims require shell dispatch through resolveSpawnCommand.
102 - const resolved = yield* resolveSpawnCommand(input.command, input.args);
103 + const resolved = yield* resolveSpawnCommand(input.command, input.args, env);
104 const child = yield* input.spawner
105 .spawn(
106 ChildProcess.make(resolved.command, resolved.args, {
107 shell: resolved.shell,
107 - ...(input.env ? { env: input.env, extendEnv: true } : {}),
108 + ...env,
109 }),
110 )
111 .pipe(
packages/provider-core/src/server/maintenance.ts
+1 -1
@@ -24,6 +24,6 @@ export interface ProviderMaintenanceCommandAction {
24 readonly executable: string;
25 readonly args: ReadonlyArray<string>;
26 readonly lockKey: string;
27 - /** Native updaters must use the instance's custom home (e.g. `CODEX_HOME`). */
27 + /** The provider's environment, including its PATH and custom home. */
28 readonly env?: NodeJS.ProcessEnv;
29 }
packages/provider-core/src/server/maintenanceResolver.test.ts
+12 -6
@@ -234,7 +234,7 @@ it.layer(
234 let probes = 0;
235 const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
236 fixture.install === "native" ? nativePackageToolUpdate : packageToolUpdate,
237 - { binaryPath, env: { PATH: "" } },
237 + { binaryPath, env: { PATH: fixture.install === "npm" ? npmBinDir : "" } },
238 ).pipe(
239 Effect.provideService(HostProcess.Environment, { PATH: npmBinDir }),
240 Effect.provideService(
@@ -416,7 +416,7 @@ it.layer(
416 );
417
418 it.effect.skipIf(!symlinksSupported)(
419 - "pins npm updates to the global prefix that owns the package",
419 + "pins npm updates to the global prefix that owns the package and the provider's PATH",
420 () =>
421 Effect.gen(function* () {
422 const tempDir = yield* makeTempDir("t3-npm-capabilities");
@@ -426,12 +426,14 @@ it.layer(
426 "@example",
427 "package-tool",
428 ]);
429 + // A version manager's Node, which only the provider's settings put on PATH.
430 + const providerEnv = { PATH: NodePath.join(tempDir, "bin") };
431
432 const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
433 packageToolUpdate,
434 {
435 binaryPath: link,
434 - env: { PATH: "" },
436 + env: providerEnv,
437 },
438 ).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));
439
@@ -450,6 +452,7 @@ it.layer(
452 "@example/package-tool@latest",
453 ],
454 lockKey: `npm-global:${normalizeCommandPath(tempDir)}`,
455 + env: providerEnv,
456 },
457 });
458 }),
@@ -922,7 +925,8 @@ it.layer(
925
926 it.effect.each([
927 {
925 - case: "the eligible release",
928 + case: "the eligible release with an inherited PATH",
929 + inheritPath: true,
930 outdated: { "@example/package-tool": { current: "1.0.0", latest: "1.1.0" } },
931 exitCode: 1,
932 npmOutput: '"1.2.0"',
@@ -977,9 +981,11 @@ it.layer(
981 let npmProbes = 0;
982 const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
983 packageToolUpdate,
980 - { binaryPath: link, env: { PATH: "" } },
984 + { binaryPath: link, env: fixture.inheritPath ? {} : { PATH: pnpmBinDir } },
985 ).pipe(
982 - Effect.provideService(HostProcess.Environment, { PATH: pnpmBinDir }),
986 + Effect.provideService(HostProcess.Environment, {
987 + PATH: fixture.inheritPath ? pnpmBinDir : "",
988 + }),
989 Effect.provideService(
990 ChildProcessSpawner.ChildProcessSpawner,
991 stdoutSpawner(
packages/provider-core/src/server/maintenanceResolver.ts
+17 -7
@@ -424,15 +424,18 @@ const decodePnpmList = Schema.decodeUnknownOption(
424 // Unlike npm's latest tag, pnpm outdated respects minimumReleaseAge and its excludes.
425 const resolvePnpmGlobalLatestVersion = Effect.fn("resolvePnpmGlobalLatestVersion")(function* (
426 packageName: string,
427 + env: NodeJS.ProcessEnv,
428 ) {
428 - // Match the updater's pnpm and server environment, rather than the instance's.
429 - const pnpmPath = yield* resolveCommandPath("pnpm");
429 + // Match the updater's pnpm and environment.
430 + const pnpmPath = yield* resolveCommandPath("pnpm", {
431 + env: { ...(yield* HostProcess.Environment), ...env },
432 + });
433 if (!pnpmPath) return null;
434 // Silent reporting keeps project package-manager warnings out of the JSON.
435 const outdated = yield* runProbe(
436 pnpmPath,
437 ["outdated", "-g", "--reporter=silent", "--format", "json", packageName],
435 - {},
438 + env,
439 // pnpm outdated exits 1 when updates are available.
440 [0, 1],
441 );
@@ -446,7 +449,7 @@ const resolvePnpmGlobalLatestVersion = Effect.fn("resolvePnpmGlobalLatestVersion
449 const listed = yield* runProbe(
450 pnpmPath,
451 ["ls", "-g", "--reporter=silent", "--depth", "0", "--json", packageName],
449 - {},
452 + env,
453 );
454 const listedEntries = listed ? Option.getOrUndefined(decodePnpmList(listed)) : undefined;
455 return nonEmptyString(listedEntries?.[0]?.dependencies?.[packageName]?.version);
@@ -544,6 +547,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
547 updateExecutable: "vp",
548 updateArgs: ["i", "-g", packageName],
549 updateLockKey: "vite-plus-global",
550 + env: context.env,
551 });
552 }
553 if (commandPaths.some(isBunGlobalCommandPath)) {
@@ -553,6 +557,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
557 updateExecutable: "bun",
558 updateArgs: ["i", "-g", `${packageName}@latest`],
559 updateLockKey: "bun-global",
560 + env: context.env,
561 });
562 }
563 if (commandPaths.some(isPnpmGlobalCommandPath)) {
@@ -569,7 +574,8 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
574 updateExecutable: "pnpm",
575 updateArgs: ["add", "-g", ...allowBuild, `${packageName}@latest`],
576 updateLockKey: "pnpm-global",
572 - lookupLatestVersion: resolvePnpmGlobalLatestVersion(packageName).pipe(
577 + env: context.env,
578 + lookupLatestVersion: resolvePnpmGlobalLatestVersion(packageName, context.env).pipe(
579 Effect.provideContext(services),
580 ),
581 });
@@ -582,6 +588,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
588 updateExecutable: "yarn",
589 updateArgs: ["global", "add", `${packageName}@latest`],
590 updateLockKey: "yarn-global",
591 + env: context.env,
592 });
593 }
594 if (yield* isVoltaPackageInstall(context, packageName)) {
@@ -591,6 +598,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
598 updateExecutable: "volta",
599 updateArgs: ["install", `${packageName}@latest`],
600 updateLockKey: "volta",
601 + env: context.env,
602 });
603 }
604
@@ -611,6 +619,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
619 `${packageName}@latest`,
620 ],
621 updateLockKey: `npm-global:${normalizeCommandPath(npmPrefix)}`,
622 + env: context.env,
623 });
624 }
625
@@ -781,7 +790,8 @@ const withConfiguredNpmVersionLookup = Effect.fn("withConfiguredNpmVersionLookup
790 if (!packageName || capabilities.latestVersion !== undefined) {
791 return capabilities;
792 }
784 - const npmPath = yield* resolveCommandPath("npm");
793 + const env = { ...(yield* HostProcess.Environment), ...capabilities.update?.env };
794 + const npmPath = yield* resolveCommandPath("npm", { env });
795 if (!npmPath) return capabilities;
796 const services = yield* Effect.context<ProviderMaintenanceResolverServices>();
797 const update = capabilities.update;
@@ -799,7 +809,7 @@ const withConfiguredNpmVersionLookup = Effect.fn("withConfiguredNpmVersionLookup
809 `${packageName}@latest`,
810 "version",
811 ],
802 - {},
812 + env,
813 ).pipe(
814 Effect.map((stdout) => {
815 const value = stdout ? Option.getOrNull(decodeNpmViewVersion(stdout.trim())) : null;