Skip to content

Commit 7047bd6

Browse files
fix(server): npm installs behind the native launcher path keep npm's latest version
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 893a091 commit 7047bd6

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎packages/provider-core/src/server/maintenanceResolver.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,44 @@ it.layer(
966966
}),
967967
);
968968

969+
it.effect.skipIf(!symlinksSupported)(
970+
"keeps npm's latest version for an npm install whose launcher is in the native location",
971+
() =>
972+
Effect.gen(function* () {
973+
const tempDir = yield* makeTempDir("t3-native-npm-prefix");
974+
const target = NodePath.join(
975+
tempDir,
976+
".local",
977+
"lib",
978+
"node_modules",
979+
"@example",
980+
"native-package-tool",
981+
"bin",
982+
"native-package-tool",
983+
);
984+
writeExecutable(target);
985+
const launcher = NodePath.join(tempDir, ".local", "bin", "native-package-tool");
986+
NodeFS.mkdirSync(NodePath.dirname(launcher), { recursive: true });
987+
NodeFS.symlinkSync(target, launcher);
988+
989+
const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
990+
makePackageManagedProviderMaintenanceResolver({
991+
provider: driver("nativePackageTool"),
992+
npmPackageName: "@example/native-package-tool",
993+
nativeUpdate: {
994+
args: ["update"],
995+
isCommandPath: isNativeTestCommandPath("/.local/bin/native-package-tool"),
996+
lookupLatestVersion: Effect.die("an npm install should not read the native feed"),
997+
},
998+
}),
999+
{ binaryPath: launcher, env: { PATH: "" } },
1000+
).pipe(Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, noSpawn));
1001+
1002+
expect(capabilities.update?.args).toEqual(["update"]);
1003+
expect(capabilities.latestVersion).toBeUndefined();
1004+
}),
1005+
);
1006+
9691007
it.effect.each(["wrapper", "symlink"])(
9701008
"keeps a mise-owned %s in a native install location manual-only",
9711009
(launcher, { skip }) => {

‎packages/provider-core/src/server/maintenanceResolver.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,11 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
472472
!commandPaths.some(isMiseCommandPath) &&
473473
!(yield* isMiseWrapperScript(context))
474474
) {
475-
return nativeUpdate.lookupLatestVersion
475+
// An npm `--prefix ~/.local` install shares the launcher path but follows npm's releases.
476+
const followsReleaseFeed = !commandPaths.some((commandPath) =>
477+
normalizeCommandPath(commandPath).includes("/node_modules/"),
478+
);
479+
return nativeUpdate.lookupLatestVersion && followsReleaseFeed
476480
? { ...native, latestVersion: null, lookupLatestVersion: nativeUpdate.lookupLatestVersion }
477481
: native;
478482
}

0 commit comments

Comments
 (0)