fix: repair broken Electron install on macOS via system unzip - #11
Open
dan-nyanko wants to merge 2 commits into
Open
fix: repair broken Electron install on macOS via system unzip#11dan-nyanko wants to merge 2 commits into
dan-nyanko wants to merge 2 commits into
Conversation
jsdom does not reliably expose localStorage across runtimes (e.g. Node 26's experimental built-in shadows it), causing projectsPersistence/projectsSlice tests to fail with 'localStorage is undefined'. Add a minimal in-memory shim guarded by typeof check so it only applies when absent, keeping behavior identical on environments where jsdom already provides it.
Electron's install.js uses extract-zip, which on some macOS machines silently extracts only a stub (no Frameworks), causing "Electron failed to install correctly". Add an idempotent postinstall (scripts/ensure-electron.js) that detects a broken install and re-extracts the cached archive with the system unzip tool.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On macOS,
pnpm installcould leave Electron in a broken state whererequire('electron')fails with "Electron failed to install correctly". This adds apostinstallstep (scripts/ensure-electron.js) that detects the broken state and re-extracts the cached Electron archive using the systemunziptool.Root cause
Electron's own
install.jsextracts viaextract-zip, which on some systems silently extracts only a stub (noFrameworks), leaving a broken install. Upstream issue: electron/electron#51619 — extraction fails under newer Node.js versions because of a bug inextract-zip(yauzl/fd-slicer); the cached zip is present butdistis incomplete.Fix
scripts/ensure-electron.jspostinstall:isUsable()checks thatrequire('electron')resolves and (on macOS) thatdist/Electron.app/Contents/Frameworksexists.electron-v<version>-<platform>-<arch>.zip(also checks the opposite arch under Rosetta, and any-version fallback), removes the stubdist, and re-extracts it with the systemunzip.unzip(e.g. Windows), falls back to Electron's own installer.try/catchand never fails the install — it only logs a warning and exits0sopnpm installalways succeeds.package.json: added"ensure-electron": "node scripts/ensure-electron.js"and"postinstall": "node scripts/ensure-electron.js".Testing
rm -rf node_modules && pnpm install→ postinstall detects/repairs viaunzip;require('electron')resolves.electron/package.json(repair only warns, install still succeeds).pnpm run lint,pnpm run format:check,pnpm run typecheck→ all pass (the script is plain JS, not covered by src lint/typecheck but formatted by prettier).Note
This is a workaround until electron/electron#51619 is fixed upstream. The script is a no-op when the install is already usable.