fix(unix): don't rewrite app.asar.unpacked paths a second time - #924
fix(unix): don't rewrite app.asar.unpacked paths a second time#924arthur791004 wants to merge 1 commit into
Conversation
helperPath.replace('app.asar', 'app.asar.unpacked') matches the first
occurrence. When helperPath already contains 'app.asar.unpacked/...'
(e.g. a caller of node-pty that itself lives inside app.asar.unpacked,
bypassing Electron's asar shim), the substring 'app.asar' matches the
prefix of 'app.asar.unpacked' and we produce 'app.asar.unpacked.unpacked/...'
— a path that doesn't exist on disk. posix_spawn then fails with ENOENT
and node-pty throws the misleading "posix_spawnp failed.".
Skip each rewrite when the unpacked variant is already present.
Fixes microsoft#923.
|
Hi — we hit this exact bug in a packaged Electron app on macOS 26 and verified your fix end-to-end. Sharing the evidence and a suggestion: Reproduction (real runtime): loading node-pty 1.1.0 from an asar layout where it lives under Your patch works: with the guarded rewrite applied, a real Suggestion — this needs tests: the inline rewrite is untestable as written. I've opened #953 which extracts |
Summary
Fixes #923.
src/unixTerminal.ts#L19-L20does:String.prototype.replacewith a string argument matches the first occurrence. When the resolved `helperPath` already contains `app.asar.unpacked/…` (e.g. a caller of node-pty that itself lives inside `app.asar.unpacked`, bypassing Electron's asar shim — see #923 for the concrete repro), the substring `app.asar` matches the prefix of `app.asar.unpacked` and we produce a bogus `…/app.asar.unpacked.unpacked/…` path. `posix_spawn` then fails with `ENOENT` and node-pty surfaces the misleading `posix_spawnp failed.`.This PR guards each rewrite so it only fires when the unpacked variant isn't already present.
Test plan