/ide install fails on Windows: the code.cmd path contains spaces and is not quoted for cmd.exe
What happened?
On Windows, /ide install cannot install the VS Code companion extension when VS Code is in its default folder. Answering Yes to "Do you want to connect VS Code to Gemini CLI?" fails the same way, because that prompt runs /ide install.
What Gemini CLI prints in VS Code's integrated terminal:
> /ide install
ℹ Installing IDE companion...
✗ Failed to install VS Code companion extension. Please try installing 'Gemini CLI Companion' manually from the VS Code extension marketplace.
Root cause. packages/core/src/ide/ide-installer.ts resolves the CLI with where.exe code.cmd, or falls back to the default install folders. It then runs:
child_process.spawnSync(
commandPath,
['--install-extension', 'google.gemini-cli-vscode-ide-companion', '--force'],
{ stdio: 'pipe', shell: this.platform === 'win32' },
);
Windows needs shell: true to start a .cmd file; without it Node fails with EINVAL, which is why #9995 added it. With shell: true, though, Node does not quote anything. It joins the command and the arguments with spaces and runs cmd.exe /d /s /c "<joined text>". Both default VS Code folders contain spaces (...\Microsoft VS Code\bin\code.cmd), so cmd.exe cuts the path at the first space and exits with status 1. install() then shows only the generic "Failed to install" message, so the real reason never reaches the user. Positron and Antigravity use the same code path.
Minimal reproduction (plain Node on Windows, no Gemini CLI or real VS Code needed). It creates a fake code.cmd inside a folder named Microsoft VS Code, then makes the installer's call, once as today and once with the path quoted:
import { spawnSync } from 'node:child_process';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
const root = mkdtempSync(join(tmpdir(), 'ide-repro-'));
const bin = join(root, 'Microsoft VS Code', 'bin');
mkdirSync(bin, { recursive: true });
const cli = join(bin, 'code.cmd');
writeFileSync(cli, '@echo off\r\necho code.cmd ran with: %*\r\n');
const args = ['--install-extension', 'google.gemini-cli-vscode-ide-companion', '--force'];
const output = (r) => `${r.stdout}${r.stderr}`.trim();
const before = spawnSync(cli, args, { stdio: 'pipe', shell: true }); // today's call
console.log(`today: status=${before.status} ${output(before)}`);
const after = spawnSync(`"${cli}"`, args, { stdio: 'pipe', shell: true }); // path quoted
console.log(`quoted: status=${after.status} ${output(after)}`);
rmSync(root, { recursive: true, force: true });
Output on my machine:
today: status=1 'C:\Users\<user>\AppData\Local\Temp\ide-repro-ezBG3z\Microsoft' is not recognized as an internal or external command,
operable program or batch file.
quoted: status=0 code.cmd ran with: --install-extension google.gemini-cli-vscode-ide-companion --force
What did you expect to happen?
/ide install should install the companion extension and print "VS Code companion extension was installed successfully.", as it does on macOS and Linux, including when VS Code is in its default folder (and likewise for Positron and Antigravity installed under a path with spaces).
Client information
Client Information
- Gemini CLI 0.68.0 (
npx -y @google/gemini-cli@latest), run in VS Code's integrated terminal (PowerShell) - Platform: Windows 11 Pro 26H2 (build 26300.9711), Node.js 24.15.0
where.exe code.cmd:C:\Users\<user>\AppData\Local\Programs\Microsoft VS Code\bin\code.cmd
Happy to add the full /about output if useful.
Login information
Not relevant here: the failure is the local code.cmd call, before any model request.
Anything else we need to know?
- The same code is on current
main(e5d88fb2c). - Earlier Windows reports with this symptom were closed without a root cause: #12528 (0.11.3), #15622 (0.22.4), #17033 (0.24.4).
openDiffhad the same problem and was fixed in #29753 withquoteCmdArg()inpackages/core/src/utils/editor.ts. Quoting the CLI path with that same helper on Windows fixes this too; macOS and Linux need no change, since they run the CLI without a shell.- Workaround: install "Gemini CLI Companion" from the VS Code Marketplace manually, then run
/ide enable. - I have a fix with unit tests ready (it reuses
quoteCmdArg()on Windows only). If this suits a community contribution, could a maintainer addhelp wanted? I'll open the PR and link it here.
Effort Analysis:
The packages/core/src/ide/ide-installer.ts component resolves the VS Code CLI executable (code.cmd) and attempts to install the IDE companion extension using child_process.spawnSync. On Windows, the process sets shell: true to execute the .cmd file. However, Node.js joins the command and arguments with spaces and passes them to cmd.exe /d /s /c, which fails to properly quote executable paths containing spaces (e.g., the default 'Microsoft VS Code' installation folder). This causes cmd.exe to prematurely cut the path at the first space, resulting in an exit status of 1. Resolving this requires adjusting the command path quoting and execution strategy specifically for Windows. Per the categorization guidelines, any issue involving child_process.spawn, OS-level shell behavior (Windows cmd.exe semantics), and platform-specific complexities (requiring VS Code cross-environment setup) must be categorized as effort/large.
The bot will close #30246 around 26 Nov, because this issue doesn't have the help wanted label.
Could a maintainer take a look and either add the label, or say if you'd rather fix this internally? Either is fine with me. I'd just like someone on the team to see it before the PR closes.
Short version: on Windows, /ide install fails whenever VS Code is in its default folder, because cmd.exe cuts the unquoted ...\Microsoft VS Code\bin\code.cmd path at the first space. #30246 quotes the path for cmd.exe and adds tests for it.