Skip to content

fix(desktop): install the Electron binary before dev - #174

Merged
quickbeard merged 2 commits into
mainfrom
desktop-electron-install
Aug 12, 2026
Merged

quickbeard merged 2 commits into
mainfrom
desktop-electron-install

Conversation

@quickbeard

Copy link
Copy Markdown
Owner

What

bun dev:desktop was dead on a fresh clone:

error during start dev server and electron app:
Error: Electron uninstall
    at getElectronPath (.../electron-vite/dist/chunks/lib-….js:155:19)

Electron 42 removed the postinstall hook that downloaded the platform binary and exposes it as an install-electron bin the consumer must call — electron 41's published manifest still has "postinstall": "node install.js", 42.3.3's has no scripts field at all. So bun install leaves packages/desktop/node_modules/electron with no dist/ and no path.txt, and electron-vite dev aborts in getElectronPath before it can spawn anything.

packages/desktop/scripts/predev.ts now runs bun run install-electron ahead of the icon copy and the node-sidecar build.

Why predev and not the root postinstall

Only someone actually launching the desktop app should pay the ~100 MB download (cached in ~/.cache/electron), and install.js short-circuits when dist/version + path.txt already match package.json — measured 47 ms on a warm tree, so repeat bun dev:desktop runs cost nothing.

Not added to prebuild/package: electron-vite build never spawns Electron, and electron-builder fetches its own copy through @electron/get.

Also

  • README — new "bun dev:desktop fails with 'Error: Electron uninstall'" subsection under Development explaining the cause, the standalone bun --cwd packages/desktop run install-electron command, and how to recover from a partial download. bun dev:desktop added to the command list.
  • DIVERGENCES.md — row for packages/desktop/scripts/predev.ts (upstream file), with the on-conflict guidance to drop the line if upstream adds its own install step or pins Electron back below 42.

No CHANGELOG entry: this is dev-environment setup, not user-facing product behavior.

Test plan

  • bun --cwd packages/desktop run install-electron downloads dist/ + writes path.txt (electron 42.3.3, linux x64), and re-running exits 0 in 47 ms.
  • bun dev:desktop on this branch runs predev → vite → launches the Electron window and reaches "server ready"; previously it exited 1 at getElectronPath.
  • npx prettier --check README.md passes.

🤖 Generated with Claude Code

Electron 42 dropped the postinstall hook that downloaded the platform
binary and exposes it as an `install-electron` bin the consumer has to
call, so `bun install` left `node_modules/electron` without a `dist/`
and `bun dev:desktop` died with `Error: Electron uninstall` before the
app could launch. `predev` now runs the installer; it short-circuits
once the binary matches package.json, so repeat runs are free.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard force-pushed the desktop-electron-install branch from 1371573 to 0a7e51d Compare August 12, 2026 08:00
The predev hook now installs the binary automatically, so the failure
the section documented no longer reaches a fresh clone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard merged commit 7227d76 into main Aug 12, 2026
0 of 5 checks passed
@quickbeard
quickbeard deleted the desktop-electron-install branch August 12, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant