fix(tools): resolve PowerShell ENOENT by using full path on Windows#12085
Open
octo-patch wants to merge 1 commit intocontinuedev:mainfrom
Open
fix(tools): resolve PowerShell ENOENT by using full path on Windows#12085octo-patch wants to merge 1 commit intocontinuedev:mainfrom
octo-patch wants to merge 1 commit intocontinuedev:mainfrom
Conversation
The run_terminal_command tool fails with 'spawn powershell.exe ENOENT' when the VSCode extension host process PATH does not include Windows system directories (e.g. %SystemRoot%\System32). Use the full path to powershell.exe derived from the SystemRoot environment variable (always present on Windows) instead of relying on PATH resolution. Falls back to C:\Windows if SystemRoot is unset. Fixes continuedev#12079
Contributor
|
I have read the CLA Document and I hereby sign the CLA octo-patch seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
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.
Fixes #12079
Problem
On Windows, the
run_terminal_commandtool fails withspawn powershell.exe ENOENTfor all terminal commands (even simple ones likeecho "test"). File creation/editing tools work fine, but nothing that uses the terminal works.The root cause is that the VSCode extension host process may run with a minimal PATH that does not include
%SystemRoot%\System32(e.g.C:\Windows\System32), wherepowershell.exelives. Whenchild_process.spawn("powershell.exe", ...)is called without a full path, Node.js fails to locate the executable.Solution
Replace the bare
"powershell.exe"shell name with the full absolute path constructed from theSystemRootenvironment variable, which is always present on Windows:SystemRootis a guaranteed Windows environment variable that points to the Windows installation directory (typicallyC:\Windows). Using it avoids any dependency on the PATH being set correctly in the extension host.Testing
elsebranch handles Unix/macOS).powershell.exeis now resolved via the full path fromSystemRoot, bypassing PATH lookup issues.runTerminalCommandImplfunction and should continue to pass.Summary by cubic
Fixes Windows terminal commands failing with "spawn powershell.exe ENOENT" by invoking PowerShell via its absolute path built from the
SystemRootenv var (fallback to C:\Windows) instead of relying on PATH. No behavior change on macOS/Linux.Written for commit 8bdb84d. Summary will update on new commits.