The best way to control Claude Code, Codex and more from any computer or phone
fix(server): preserve native provider executable paths during updates (#9850)
Julius Marminge committed
Sep 4, 2026 at 17:39 UTC
2d5464afbc19058be8c125d5ee70481d721d14f4
2 files changed
+53
-6
apps/server/src/provider/providerMaintenance.test.ts
+50
-4
@@ -1,6 +1,7 @@
1
// @effect-diagnostics nodeBuiltinImport:off
2
import { expect, it } from "@effect/vitest";
3
import * as NodeFS from "node:fs";
4
+import * as NodeChildProcess from "node:child_process";
5
import * as NodeServices from "@effect/platform-node/NodeServices";
6
import * as NodeOS from "node:os";
7
import * as NodePath from "node:path";
@@ -8,6 +9,7 @@ import { ProviderDriverKind, ProviderInstanceId, type ServerProvider } from "@t3
9
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
10
import * as Crypto from "effect/Crypto";
11
import * as Effect from "effect/Effect";
12
+import * as FileSystem from "effect/FileSystem";
13
import { HttpClient } from "effect/unstable/http";
14
import {
15
createProviderVersionAdvisory,
@@ -362,9 +364,9 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
364
provider: driver("nativePackageTool"),
365
packageName: "@example/native-package-tool",
366
update: {
365
- command: "native-package-tool update",
367
+ command: `${nativePackageToolPath} update`,
368
367
- executable: "native-package-tool",
369
+ executable: nativePackageToolPath,
370
371
args: ["update"],
372
@@ -399,9 +401,9 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
401
provider: driver("scopedPackageTool"),
402
packageName: "@example/scoped-package-tool",
403
update: {
402
- command: "scoped-package-tool upgrade",
404
+ command: `${scopedPackageToolPath} upgrade`,
405
404
- executable: "scoped-package-tool",
406
+ executable: scopedPackageToolPath,
407
408
args: ["upgrade"],
409
@@ -411,6 +413,50 @@ it.layer(NodeServices.layer)("providerMaintenance", (it) => {
413
}),
414
);
415
416
+ it.effect.skipIf(windowsHost)("runs an explicit native updater outside PATH", () =>
417
+ Effect.gen(function* () {
418
+ const fs = yield* FileSystem.FileSystem;
419
+ const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-native-update-" });
420
+ const nativeBinDir = NodePath.join(tempDir, "with spaces", ".scoped-package-tool", "bin");
421
+ yield* fs.makeDirectory(nativeBinDir, { recursive: true });
422
+ const binaryPath = NodePath.join(nativeBinDir, "scoped-package-tool");
423
+ yield* fs.writeFileString(binaryPath, "#!/bin/sh\nprintf '%s' \"$1\"\n");
424
+ yield* fs.chmod(binaryPath, 0o755);
425
+
426
+ const capabilities = yield* resolveProviderMaintenanceCapabilitiesEffect(
427
+ scopedPackageToolUpdate,
428
+ { binaryPath, env: { PATH: "" } },
429
+ );
430
+ const update = capabilities.update;
431
+ expect(update).not.toBeNull();
432
+ if (!update) return;
433
+ const result = NodeChildProcess.spawnSync(update.executable, update.args, {
434
+ env: { PATH: "" },
435
+ encoding: "utf8",
436
+ });
437
+ expect(result.error).toBeUndefined();
438
+ expect(result.status).toBe(0);
439
+ expect(result.stdout).toBe("upgrade");
440
+ }).pipe(Effect.scoped),
441
+ );
442
+
443
+ it.each([
444
+ "/Users/example/.local/bin/native-package-tool",
445
+ "C:\\Users\\Example User\\.local\\bin\\native-package-tool.exe",
446
+ ])("preserves a configured native executable path: %s", (binaryPath) => {
447
+ expect(nativePackageToolUpdate.resolve({ binaryPath }).update?.executable).toBe(binaryPath);
448
+ });
449
+
450
+ it("uses the resolved launcher when its symlink target identifies a native install", () => {
451
+ const launcher = "/custom tools/native-launcher";
452
+ const capabilities = nativePackageToolUpdate.resolve({
453
+ binaryPath: launcher,
454
+ resolvedCommandPath: launcher,
455
+ realCommandPath: "/Users/example/.local/bin/native-package-tool",
456
+ });
457
+ expect(capabilities.update?.executable).toBe(launcher);
458
+ });
459
+
460
it("switches native-package-tool to Homebrew updates when the binary resolves through Homebrew", () => {
461
expect(
462
nativePackageToolUpdate.resolve({
apps/server/src/provider/providerMaintenance.ts
+3
-2
@@ -209,6 +209,7 @@ function makeHomebrewProviderMaintenanceCapabilities(
209
210
function makeNativeProviderMaintenanceCapabilities(
211
definition: PackageManagedProviderMaintenanceDefinition,
212
+ commandPath: string,
213
): ProviderMaintenanceCapabilities | null {
214
if (!definition.nativeUpdate) {
215
return null;
@@ -217,7 +218,7 @@ function makeNativeProviderMaintenanceCapabilities(
218
return makeProviderMaintenanceCapabilities({
219
provider: definition.provider,
220
packageName: definition.npmPackageName,
220
- updateExecutable: definition.nativeUpdate.executable,
221
+ updateExecutable: commandPath,
222
updateArgs: definition.nativeUpdate.args,
223
updateLockKey: definition.nativeUpdate.lockKey,
224
});
@@ -297,7 +298,7 @@ export function resolvePackageManagedProviderMaintenance(
298
commandPaths.some((commandPath) => nativeUpdate.isCommandPath(commandPath))
299
) {
300
return (
300
- makeNativeProviderMaintenanceCapabilities(definition) ??
301
+ makeNativeProviderMaintenanceCapabilities(definition, resolvedCommandPath) ??
302
makeNpmGlobalProviderMaintenanceCapabilities(definition)
303
);
304
}