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 |
|
Thanks for the verification and for adding the tests — that's a good improvement over what I had here. I'm fine either way 🙂 |
|
Thanks! Happy to defer to whichever variant is easier to maintain upstream — glad the tests are useful either way. |
|
Downstream confirmation from OpenAI Codex Desktop: this exact path-rewrite failure is present in build In the shipped bundle:
The Xcode license and first-launch setup are already complete in this reproduction, so that reported workaround is not applicable. The guard in this PR directly addresses the observed bundled path. Linking the downstream report here to help with impact/priority; no private paths or logs are included. |
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