You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Windows when editor is set to use VSCode, the /editor command fails as below.
$ aider --editor "code --wait"
──────────────────────────────────────────────────────────────────────────────────
Aider v0.72.1
Model: deepseek/deepseek-chat with diff edit format, prompt cache, infinite output
Git repo: .git with 26 files
Repo-map: using 4096 tokens, auto refresh
──────────────────────────────────────────────────────────────────────────────────
> /editor
Unable to complete editor: [WinError 2] The system cannot find the file specified
──────────────────────────────────────────────────────────────────────────────────
>
Cause
The /editor command runs the editor command via subprocess.call(command_parts) at https://github.com/Aider-AI/aider/blob/v0.72.1/aider/editor.py#L133, which on windows, the code command isn't recognised. A simple demo of this is running this script on a Windows machine with VSCode installed:
importsubprocesssubprocess.call(["code"])
# $ python test.py# Traceback (most recent call last):# File "C:\path\test.py", line 17, in <module># subprocess.call(["code"])# File "C:\path\anaconda3\envs\aider\Lib\subprocess.py", line 389, in call# with Popen(*popenargs, **kwargs) as p:# ^^^^^^^^^^^^^^^^^^^^^^^^^^^# File "C:\path\anaconda3\envs\aider\Lib\subprocess.py", line 1026, in __init__# self._execute_child(args, executable, preexec_fn, close_fds,# File "C:\path\anaconda3\envs\aider\Lib\subprocess.py", line 1538, in _execute_child# hp, ht, pid, tid = _winapi.CreateProcess(executable, args,# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^# FileNotFoundError: [WinError 2] The system cannot find the file specified
Possible explaination
When you install VS Code on windows, it adds code.cmd (a batch file) to your PATH, not a true .exe:
importsubprocesssubprocess.call(["where", "code"])
# C:\path\Programs\Microsoft VS Code\bin\code # No extension# C:\path\Programs\Microsoft VS Code\bin\code.cmd # .cmd
Batch files can't be executed directly by Python's subprocess with shell=False (the default). They require cmd.exe to interpret them.
With shell=False (default), subprocess uses the Windows API CreateProcess, which:
Only recognizes .exe, .com, or .bat files directly (but .cmd files require explicit handling).
Doesn't understand shell-specific features like aliases or batch file execution.
Even if code is in your PATH, CreateProcess fails because it's looking for code.exe (which doesn't exist), not code.cmd.
Solutions
For now, a simple workaround users can do is to use cmd /c code --wait instead of code --wait:
aider --editor "cmd /c code --wait"
And a simple fix would be to run subprocess.call with shell=True. But I'm not sure what consequence shell=True would entail.
I do think /editor should use the current terminal type though. Like if I started aider in Git bash, I'd assume the /editor command would run in Git bash rather than CMD. Perhaps we could use run_cmd_subprocess() in aider/run_cmd.py?
Version and model info
Aider v0.72.1
Model: deepseek/deepseek-chat with diff edit format, prompt cache, infinite output
Git repo: .git with 26 files
Repo-map: using 4096 tokens, auto refresh
The text was updated successfully, but these errors were encountered:
Issue
The problem
On Windows when editor is set to use VSCode, the
/editor
command fails as below.Cause
The
/editor
command runs the editor command viasubprocess.call(command_parts)
at https://github.com/Aider-AI/aider/blob/v0.72.1/aider/editor.py#L133, which on windows, thecode
command isn't recognised. A simple demo of this is running this script on a Windows machine with VSCode installed:Possible explaination
When you install VS Code on windows, it adds
code.cmd
(a batch file) to your PATH, not a true.exe
:Batch files can't be executed directly by Python's subprocess with shell=False (the default). They require
cmd.exe
to interpret them.With shell=False (default), subprocess uses the Windows API CreateProcess, which:
.exe
,.com
, or.bat
files directly (but.cmd
files require explicit handling).Even if code is in your PATH, CreateProcess fails because it's looking for code.exe (which doesn't exist), not
code.cmd
.Solutions
For now, a simple workaround users can do is to use
cmd /c code --wait
instead ofcode --wait
:aider --editor "cmd /c code --wait"
And a simple fix would be to run
subprocess.call
withshell=True
. But I'm not sure what consequenceshell=True
would entail.I do think
/editor
should use the current terminal type though. Like if I started aider in Git bash, I'd assume the/editor
command would run in Git bash rather than CMD. Perhaps we could userun_cmd_subprocess()
inaider/run_cmd.py
?Version and model info
Aider v0.72.1
Model: deepseek/deepseek-chat with diff edit format, prompt cache, infinite output
Git repo: .git with 26 files
Repo-map: using 4096 tokens, auto refresh
The text was updated successfully, but these errors were encountered: