diff --git a/gitnexus-desktop/electron-builder.yml b/gitnexus-desktop/electron-builder.yml index 61fa41057..29029f3a8 100644 --- a/gitnexus-desktop/electron-builder.yml +++ b/gitnexus-desktop/electron-builder.yml @@ -32,6 +32,12 @@ extraResources: - '**/*' - from: '${env.GITNEXUS_DESKTOP_GITNEXUS_PACKAGE_JSON}' to: gitnexus/package.json + - from: '${env.GITNEXUS_DESKTOP_NODE_BINARY}' + to: runtime/node.exe + filter: + - '**/*' + platform: + - win asar: false npmRebuild: false win: diff --git a/gitnexus-desktop/scripts/package.mjs b/gitnexus-desktop/scripts/package.mjs index b261a73fe..6205511e2 100644 --- a/gitnexus-desktop/scripts/package.mjs +++ b/gitnexus-desktop/scripts/package.mjs @@ -155,6 +155,12 @@ const builderEnvironment = { GITNEXUS_DESKTOP_GITNEXUS_SKILLS: toBuilderRelativePath(path.join(gitnexusRoot, 'skills')), GITNEXUS_DESKTOP_GITNEXUS_VENDOR: toBuilderRelativePath(path.join(gitnexusRoot, 'vendor')), GITNEXUS_DESKTOP_WEB_DIST: toBuilderRelativePath(path.join(gitnexusWebRoot, 'dist')), + // On Windows, lbugjs.node PE-imports node.exe by name, which fails under Electron's binary. + // electron-builder copies this into resources/runtime/node.exe so it lands in both + // win-unpacked (smoke test) and the NSIS installer (end-user install). + // The extraResources entry in electron-builder.yml is platform: [win] so this value is + // ignored on macOS/Linux (empty string prevents electron-builder from touching it there). + GITNEXUS_DESKTOP_NODE_BINARY: process.platform === 'win32' ? process.execPath : '', }; const builderCliArgs = [ diff --git a/gitnexus-desktop/src/main/main.ts b/gitnexus-desktop/src/main/main.ts index 6d4d8714f..e0720aad5 100644 --- a/gitnexus-desktop/src/main/main.ts +++ b/gitnexus-desktop/src/main/main.ts @@ -38,6 +38,10 @@ const GITNEXUS_WEB_DEV_ROOT = path.resolve(__dirname, '../../gitnexus-web'); const GITNEXUS_WEB_DEV_ROOT_FALLBACK = path.resolve(__dirname, '../../../gitnexus-web'); const GITNEXUS_PACKAGED_RUNTIME_DIR = path.join(process.resourcesPath, 'gitnexus'); const GITNEXUS_WEB_PACKAGED_DIR = path.join(process.resourcesPath, 'gitnexus-web'); +// On Windows, native modules (e.g. lbugjs.node) PE-import node.exe by name. +// Electron's binary is not node.exe, so LoadLibrary fails with an access violation. +// Bundling a real node.exe and using it as the subprocess host avoids the crash. +const GITNEXUS_PACKAGED_NODE_BINARY = path.join(process.resourcesPath, 'runtime', 'node.exe'); const GITNEXUS_WEB_EXPECTED_MARKERS = ['