From 4db4408c289a2bd8539ecdc5dcc2efd185b92ee9 Mon Sep 17 00:00:00 2001 From: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> Date: Sat, 15 Aug 2026 23:58:27 +0530 Subject: [PATCH] fix(launcher): resolve Homebrew Cellar node paths to stable opt paths --- .../src/platform/install/launcher-runtime.ts | 8 ++++++- archive/code/test/launcher-runtime.test.ts | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/archive/code/src/platform/install/launcher-runtime.ts b/archive/code/src/platform/install/launcher-runtime.ts index e5b33f27..f5126ffa 100644 --- a/archive/code/src/platform/install/launcher-runtime.ts +++ b/archive/code/src/platform/install/launcher-runtime.ts @@ -20,8 +20,14 @@ export async function writeInstallRuntime(args: { nodeVersion: string; nodeAbi?: string | null; }): Promise { + let resolvedNodePath = args.nodePath; + const brewCellarRegex = /\/Cellar\/node\/[^/]+/i; + if (brewCellarRegex.test(resolvedNodePath)) { + resolvedNodePath = resolvedNodePath.replace(brewCellarRegex, "/opt/node"); + } + const runtime: InstallRuntime = { - nodePath: args.nodePath, + nodePath: resolvedNodePath, nodeVersion: args.nodeVersion, nodeAbi: args.nodeAbi ?? null, }; diff --git a/archive/code/test/launcher-runtime.test.ts b/archive/code/test/launcher-runtime.test.ts index 26ca3d11..c4488f6b 100644 --- a/archive/code/test/launcher-runtime.test.ts +++ b/archive/code/test/launcher-runtime.test.ts @@ -42,6 +42,27 @@ describe("install launcher runtime", () => { }); }); + it("resolves Homebrew Cellar paths to stable opt paths", async () => { + await withTempHome(async (home) => { + const packageRoot = join(home, "pkg"); + await mkdir(packageRoot, { recursive: true }); + + await writeInstallRuntime({ + packageRoot, + nodePath: "/opt/homebrew/Cellar/node/26.0.0/bin/node", + nodeVersion: "v26.0.0", + nodeAbi: "147", + }); + + await expect(readInstallRuntime(packageRoot)).resolves.toEqual({ + nodePath: "/opt/homebrew/opt/node/bin/node", + nodeVersion: "v26.0.0", + nodeAbi: "147", + }); + }); + }); + + it("formats the repair message when the pinned node path is gone", () => { expect( formatMissingPinnedNodeMessage({