fix(pty): probe Windows PATH registry via absolute reg.exe#8994
Open
xianjianlf2 wants to merge 1 commit into
Open
fix(pty): probe Windows PATH registry via absolute reg.exe#8994xianjianlf2 wants to merge 1 commit into
xianjianlf2 wants to merge 1 commit into
Conversation
The in-app terminal on Windows refreshes its PATH from the persisted Environment registry keys (HKLM/HKCU) so newly installed CLIs resolve without an app restart. That probe shells out with a bare `reg.exe`. When Electron's main process inherits a PATH that omits System32 (Start Menu and service launches), a bare `reg.exe` through execFileSync/libuv throws ENOENT. node-pty spawns the shell via ConPTY, which always searches System32, so the terminal itself still opens -- but the registry probe silently fails and its additions are dropped. The in-app terminal is then left with only the stale launch-time PATH, so a CLI installed into a directory that a fresh system terminal picks up from the registry (e.g. the Cursor `agent` CLI) reports "not recognized as an internal or external command", while the same command works in a system terminal. Resolve reg.exe by its absolute System32 path, matching the existing icacls/whoami/cmd handling in win32-utils.ts. Closes stablyai#8834
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
andrewyatesai
pushed a commit
to andrewyatesai/orca-alab
that referenced
this pull request
Jul 21, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
The Windows in-app terminal refreshes its PATH from the persisted Environment registry keys (HKLM/HKCU) at spawn time, so newly installed CLIs resolve without an app restart (
readPersistedWindowsPathSegments→buildPtyHostEnv). That probe shelled out with a barereg.exe.When Electron's main process inherits a PATH that omits
System32(Start Menu and service launches), a barereg.exethroughexecFileSync/libuv throws ENOENT. node-pty spawns the shell via ConPTY, which always searches System32, so the terminal itself still opens — but the registry probe silently fails (its additions are swallowed by thecatch), leaving the in-app terminal on only the stale launch-time PATH. A CLI installed into a directory that a fresh system terminal picks up from the registry — e.g. the CursoragentCLI — then reports'agent' is not recognized as an internal or external command, while the exact same command works in a system terminal.Fix: resolve
reg.exeby its absolute System32 path, matching the existingicacls/whoami/cmdhandling inwin32-utils.ts(added there for this exact stripped-PATH reason).getRegExePath()towin32-utils.ts.windows-environment-path.tsnow uses it.reg.exe, so a stripped Electron PATH still reaches the registry.This is a correct, codebase-consistent hardening of the registry-refresh path. I could not reproduce on Windows, so I'm referencing rather than closing the issue — a maintainer can confirm it resolves the reporter's exact trigger.
Refs #8834
X: @mark86202384100