The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
fix(acp-registry): keep managed npm commands out of user PATH (#37542)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Wout Stiens committed
Nov 19, 2026 at 21:11 UTC
f6881ceba049ae2a4e97e9ea8ec28ccd6a069005
3 files changed
+27
-4
packages/provider-acp-registry/src/server/AcpRegistrySupport.test.ts
+21
@@ -511,6 +511,27 @@ describe("AcpRegistrySupport", () => {
511
const npmCommands = yield* fileSystem.readFileString(toolchain.logPath);
512
expect(npmCommands.match(/^install --global /gmu)).toHaveLength(1);
513
expect(npmCommands).toContain("install --global @example/acp@V1.2.3");
514
+
515
+ // A missing npm bin link must not select an unrelated command from the user's PATH.
516
+ const userBin = `${cacheDir}/user-bin`;
517
+ yield* fileSystem.makeDirectory(userBin);
518
+ yield* fileSystem.writeFileString(`${userBin}/example-agent`, "#!/bin/sh\n");
519
+ yield* fileSystem.chmod(`${userBin}/example-agent`, 0o755);
520
+ yield* fileSystem.remove(toolchain.executablePath);
521
+ const userEnvironment = {
522
+ ...toolchain.environment,
523
+ PATH: `${userBin}:${toolchain.environment.PATH}`,
524
+ };
525
+ const repaired = yield* resolver.resolve(settings(), "/workspace", userEnvironment);
526
+ expect(repaired.spawn.command).toBe(toolchain.executablePath);
527
+ const repairCommands = yield* fileSystem.readFileString(toolchain.logPath);
528
+ expect(repairCommands.match(/^install --global /gmu)).toHaveLength(2);
529
+
530
+ yield* fileSystem.remove(toolchain.executablePath);
531
+ const failedRepair = yield* resolver
532
+ .resolve(settings(), "/workspace", { ...userEnvironment, npm_config_bin_links: "false" })
533
+ .pipe(Effect.flip);
534
+ expect(failedRepair.reason).toBe("install_failed");
535
}).pipe(
536
Effect.scoped,
537
Effect.provide(
packages/provider-acp-registry/src/server/AcpRegistrySupport.ts
+2
-2
@@ -1241,9 +1241,9 @@ export const makeAcpRegistryCatalog = Effect.fn("AcpRegistryCatalog.make")(funct
1241
if (commandName === undefined) return Option.none<AcpRegistryPackageInstallReceipt>();
1242
const binDirectory = platform === "win32" ? globalPrefix : path.join(globalPrefix, "bin");
1243
const executablePath = resolveExecutable(
1244
- commandName,
1244
+ path.join(binDirectory, commandName),
1245
platform,
1246
- withPreferredPath(environment, binDirectory, platform),
1246
+ environment,
1247
);
1248
return executablePath === undefined
1249
? Option.none<AcpRegistryPackageInstallReceipt>()
packages/provider-acp-registry/src/server/testing/AcpRegistrySupport.npm.fixture.sh
+4
-2
@@ -19,8 +19,10 @@ if [ "$1" = "install" ] && [ "$2" = "--global" ]; then
19
executable="$prefix/bin/example-agent"
20
mkdir -p "$package_root" "$prefix/bin"
21
printf '%s' "$FAKE_NPM_MANIFEST" > "$package_root/package.json"
22
- printf '#!/bin/sh\n' > "$executable"
23
- chmod 755 "$executable"
22
+ if [ "$npm_config_bin_links" != "false" ]; then
23
+ printf '#!/bin/sh\n' > "$executable"
24
+ chmod 755 "$executable"
25
+ fi
26
exit 0
27
fi
28
exit 64