[.NET] CreateProcess fails when Copilot CLI is installed via npm (copilot.cmd)
还没有人认领这个 Issue。
评估
调研方向
从 StartCliServerAsync 和 issue 中描述的现有 ResolveCliCommand 入口点开始,然后使用通过 npm 全局安装的 Copilot CLI 在 Windows 上重现该故障。将 .NET 进程的启动行为与 Python SDK 的修复进行比较,并验证 SDK 能够启动 copilot.cmd 安装,同时保留现有的 .js 处理方式。
由索引模型根据 Issue 内容生成。
描述
Problem
On Windows, when the Copilot CLI is installed via npm, the only executables on PATH are copilot (extensionless) and copilot.cmd. There is no copilot.exe.
The .NET SDK's StartCliServerAsync uses ProcessStartInfo with UseShellExecute = false, which calls CreateProcess under the hood. CreateProcess cannot resolve .cmd/.bat files — it only finds native executables (.exe, .com). This results in:
System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'copilot'
with working directory '...'. The system cannot find the file specified.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at GitHub.Copilot.SDK.CopilotClient.StartCliServerAsync(...)
Running copilot in a terminal works fine because PowerShell/cmd.exe use PATHEXT to resolve .cmd wrappers. But the SDK's CreateProcess does not.
Output of where.exe copilot on affected machines:
C:\ProgramData\global-npm\copilot
C:\ProgramData\global-npm\copilot.cmd
This was already fixed in the Python SDK
PR #338 fixed the same issue for the Python SDK by using shutil.which() to resolve the full CLI path before spawning the subprocess.
Suggested fix for .NET
The SDK already has ResolveCliCommand which handles .js files by prepending node:
private static (string FileName, IEnumerable<string> Args) ResolveCliCommand(string cliPath, IEnumerable<string> args)
{
if (cliPath.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
{
return ("node", new[] { cliPath }.Concat(args));
}
return (cliPath, args);
}
A similar approach for .cmd files (prepending cmd.exe /c) would work. Alternatively, resolve the PATH using PATHEXT-aware logic before passing to ProcessStartInfo.
Environment
- SDK: GitHub.Copilot.SDK 0.1.32 (NuGet)
- OS: Windows 11
- CLI install method: npm (global)
- 主要语言
- Java
- 星标
- 10.5k
- 派生
- 1.5k
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 130
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/copilot-sdk 的其他 Issue
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2760 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
github/copilot-sdk#2759 ·
-
documentation
难度 1/5 1 小时以内 新手友好度 85/100
github/copilot-sdk#2758 ·
-
agentic-workflows
难度 2/5 1-3 小时 新手友好度 68/100
github/copilot-sdk#2709 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 78/100
github/copilot-sdk#2673 ·
查看 github/copilot-sdk 的全部 Issue
相似的 Issue
-
certification
难度 1/5 1 小时以内 新手友好度 80/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
[BUG] ECR GetAuthorizationToken returns a proxyEndpoint for the default region, not the request's 未关闭bug ecr
难度 2/5 1-3 小时 新手友好度 75/100
-
Needs: Triage Type: Feature request
难度 2/5 1-3 小时 新手友好度 70/100
AntennaPod/AntennaPod#8794 ·
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
难度 2/5 1-3 小时 新手友好度 75/100