copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Support $env:EDITOR being a .bat/.cmd script on Windows

Open chwarr opened this issue 8 months ago • 4 comments

Describe the feature or problem you'd like to solve

I would like to use an external editor via Ctrl-G. My external editor is opened via a wrapper Batch script

Proposed solution

Support external editors that are started via Batch (.bat/.cmd) scripts on Windows.

Example prompts or workflows

$env:EDITOR='my-editor.cmd'
copilot
# When Copilot launches, press Ctrl-G to edit the prompt in the external editor

Additional context

Today, GitHub Copilot CLI does not support your external editor being a Batch (.bat/.cmd) script. If your $env:EDITOR is something like "my-editor.cmd", pressing Ctrl-G fails with "Error: spawn EINVAL".

If $env:EDITOR is an executable, it works fine.

chwarr avatar Mar 07 '26 01:03 chwarr

Thx for filing this issue - I also stumbled over it today when trying to configure VS Code

mu88 avatar Apr 13 '26 06:04 mu88

Cross-referencing anthropics/claude-code#57215 — same root cause in another major Windows TUI consumer.

Since Node 18.20.0 / 20.12.0 / 21.7.0 (CVE-2024-27980, April 2024), child_process.spawn('<file>.cmd', ...) synchronously throws EINVAL unless shell: true is passed. A one-line fix on the Ctrl+G launch path covers .cmd and .bat together without per-extension logic:

// instead of: spawn(editor, args)
spawn(editor, args, { shell: true })
// or, with explicit dispatch:
spawn('cmd', ['/c', editor, ...args])

(Anthropic's claude-code LSP-spawn paths got this same fix for the same root cause: anthropics/claude-code#27061, #51191, #53814.)

Worth re-framing this as a bug rather than a feature request — npm-installed editors always end in .cmd on Windows, so any global npm bin used as $EDITOR errors out with Error: spawn EINVAL on Node ≥ 18.20.0.

ccstr avatar May 08 '26 07:05 ccstr

thanks for filing an issue, I have the same problem, do we know what is their cadence in terms of fixing and releasing new version.

priyankvora257 avatar May 19 '26 21:05 priyankvora257

This appears to be resolved as of GitHub Copilot CLI v1.0.85. Please update to that release or a newer stable version. We're closing this as completed. If it still happens, please comment with your version and reproduction steps.

copilot-cli-bot[bot] avatar Sep 16 '26 10:09 copilot-cli-bot[bot]