I am not asking about PowerShell syntax itself.
The PowerShell command shown below is executed internally by a VS Code extension
(Kilo Code) as part of its environment detection. The command itself works
correctly when run manually.
The actual problem is that the extension fails when invoking Git on Windows.
It appears to construct the Git executable path incorrectly when Git is installed
under "Program Files", causing the path to be split and interpreted as arguments.
When running an AI extension (Kilo Code) inside VS Code, it fails immediately with the following error:
Command failed with exit code 1:
powershell (Get-CimInstance -ClassName Win32_OperatingSystem).caption
git: 'Files\Git\cmd\git.exe' is not a git command. See 'git --help'.
From the error it looks like Git is being invoked incorrectly, as if "C:\Program Files\Git\cmd\git.exe" was split and executed as:
git Files\Git\cmd\git.exe
Environment
- OS: Windows 10 / Windows 11 (native)
- VS Code: Microsoft VS Code (stable)
- Git version: git version 2.52.0.windows.1
- Git location: C:\Program Files\Git\cmd\git.exe
What works
Git works perfectly in terminal:
git --version
where.exe git
returns correct results.
I also confirmed that PowerShell itself works:
(Get-CimInstance -ClassName Win32_OperatingSystem).caption
What I already tried
- Set VS Code setting: "git.path": "C:\Progra~1\Git\cmd\git.exe"
- Created a no-space Git wrapper: C:\Git\cmd\git.cmd which calls: "C:\Program Files\Git\cmd\git.exe" %*
- Added C:\Git\cmd to the beginning of PATH
- Verified with: where.exe git Get-Command git
- Restarted VS Code completely
- Cleared VS Code extension cache (globalStorage)
- Created new tasks (no resume)
- Verified VS Code CLI: Get-Command code -> code.cmd from VS Code installation
Despite all of this, the extension still reports:
git: 'Files\Git\cmd\git.exe' is not a git command
Question
Is this a known issue with Node.js / VS Code extensions incorrectly handling paths with spaces on Windows?
Is there any way to force a VS Code extension to use the Git executable from PATH
(or a custom git path) instead of hardcoding
%ProgramFiles%\Git\cmd\git.exe?
Or is the only solution to run the extension in WSL / wait for an extension fix?
Any insight would be appreciated.
settings.json. Relevant settings from my environment: ```json { "git.path": "C:\\Git\\cmd\\git.cmd", "kilo-code.gitPath": "C:\\Git\\cmd\\git.cmd", "kilo-code.allowedCommands": [ "git log", "git diff", "git show" ], "kilo-code.deniedCommands": [] }git.exeis clearly discoverable and executed, given that it is Git itself that reports the error. The mystery is whyFiles\Git\cmd\git.exeis being passed as an argument to the Git call.