From 59ee5c177f63828dc0768116af646cfd527ecfb0 Mon Sep 17 00:00:00 2001 From: Josh Gratton Date: Tue, 16 Jun 2026 14:07:01 -0400 Subject: [PATCH] desktop build: stage Linux native optional deps for the WSL backend Windows artifacts also ship the WSL (Linux x64) backend, which loads Linux-native optional dependencies at runtime -- e.g. ffi-rs's @yuuang/ffi-rs-linux-x64-gnu. The staged production install set pnpm's supportedArchitectures to the host platform only (win32/x64), so just the Windows bindings were fetched. The WSL backend then crash-looped on require ("Cannot find module '@yuuang/ffi-rs-linux-x64-gnu'") and never bound its port, surfacing in the app as "Couldn't connect WSL". For Windows builds, extend supportedArchitectures to also include linux/x64/glibc so the staged install pulls the Linux optional deps alongside the Windows ones. Confirmed pnpm then fetches @yuuang/ffi-rs-linux-x64-gnu into the staged tree. --- scripts/build-desktop-artifact.test.ts | 14 ++++++++++++-- scripts/build-desktop-artifact.ts | 21 +++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts index 3488013641..1e58191d12 100644 --- a/scripts/build-desktop-artifact.test.ts +++ b/scripts/build-desktop-artifact.test.ts @@ -157,10 +157,20 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => { cpu: ["x64"], }, }); + // Windows artifacts also bundle the WSL (Linux x64, glibc) backend, so the + // staged install must fetch its native optional deps (e.g. ffi-rs) too. + assert.deepStrictEqual(createStageWorkspaceConfig("win", "x64"), { + supportedArchitectures: { + os: ["win32", "linux"], + cpu: ["x64"], + libc: ["glibc"], + }, + }); assert.deepStrictEqual(createStageWorkspaceConfig("win", "arm64"), { supportedArchitectures: { - os: ["win32"], - cpu: ["arm64"], + os: ["win32", "linux"], + cpu: ["arm64", "x64"], + libc: ["glibc"], }, }); assert.deepStrictEqual(createStageWorkspaceConfig("mac", "universal"), { diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts index ae33031e15..0ee3e7fd58 100644 --- a/scripts/build-desktop-artifact.ts +++ b/scripts/build-desktop-artifact.ts @@ -42,6 +42,7 @@ const StageWorkspaceConfig = Schema.Struct({ supportedArchitectures: Schema.Struct({ os: Schema.Array(Schema.String), cpu: Schema.Array(Schema.String), + libc: Schema.optional(Schema.Array(Schema.String)), }), }); @@ -328,10 +329,26 @@ export function createStageWorkspaceConfig( platform: typeof BuildPlatform.Type, arch: typeof BuildArch.Type, ): typeof StageWorkspaceConfig.Type { + const hostOs = platform === "mac" ? "darwin" : platform === "win" ? "win32" : "linux"; + const hostCpu = arch === "universal" ? ["arm64", "x64"] : [arch]; + // Windows artifacts also bundle the WSL (Linux x64) backend, which loads + // Linux-native optional deps at runtime (e.g. @yuuang/ffi-rs-linux-x64-gnu). + // Pull the linux-x64 (glibc) variants in addition to the host platform's so + // they ship in the asar; without them the WSL backend crash-loops on require + // ("Cannot find module '@yuuang/ffi-rs-linux-x64-gnu'"). + if (platform === "win") { + return { + supportedArchitectures: { + os: Array.from(new Set([hostOs, "linux"])), + cpu: Array.from(new Set([...hostCpu, "x64"])), + libc: ["glibc"], + }, + }; + } return { supportedArchitectures: { - os: [platform === "mac" ? "darwin" : platform === "win" ? "win32" : "linux"], - cpu: arch === "universal" ? ["arm64", "x64"] : [arch], + os: [hostOs], + cpu: hostCpu, }, }; }