Description
When claudeCode.useTerminal is enabled on Windows, the VS Code extension's claude-vscode.terminal.open command resolves the claude binary using which() (npm package), which follows the Windows PATHEXT environment variable. Since PATHEXT includes .CMD but not .PS1 by default, which("claude") returns the path to claude.cmd instead of claude.ps1.
In PowerShell, the resulting command becomes & 'C:\Users\...\claude.cmd', which may fail or behave differently from running claude bare — letting PowerShell resolve it natively to claude.ps1.
Root Cause
In the bundled extension.js, the mme() function calls:
_c("claude", true) // which("claude", true)
On Windows, npm's which package iterates PATHEXT extensions. Typical PATHEXT:
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
.PS1 is absent, so which never considers claude.ps1. If claude.cmd exists anywhere in PATH, it wins.
The result is passed to ume():
function ume(e, t, r) {
if (e !== "win32" || !t) return "claude"; // fallback works fine
if (r === "powershell") return `& '${t}'`; // uses wrong binary
if (r === "cmd") return `"${t}"`;
return "claude";
}
If t is a path (the .cmd file), the fallback is never reached — PowerShell gets an explicit .cmd path instead of letting it resolve claude natively.
Expected Behavior
When the shell type is powershell, the command should let PowerShell resolve claude on its own (which correctly finds .ps1 files in PATH), either by:
- Skipping
which() resolution for PowerShell on Windows and passing bare "claude", or
- Making
which() also consider .ps1 when the target shell is PowerShell
Reproduction
- OS: Windows 11
- Extension version: 2.1.177
- Steps:
- Set
claudeCode.useTerminal: true in VS Code settings
- Have
claude.cmd and claude.ps1 both in PATH (e.g., %USERPROFILE%\bin)
- Click "Claude Code: Open in Terminal" or press
Ctrl+Escape
- The terminal runs
& 'C:\Users\...\claude.cmd' instead of resolving to claude.ps1
Description
When
claudeCode.useTerminalis enabled on Windows, the VS Code extension'sclaude-vscode.terminal.opencommand resolves theclaudebinary usingwhich()(npm package), which follows the WindowsPATHEXTenvironment variable. SincePATHEXTincludes.CMDbut not.PS1by default,which("claude")returns the path toclaude.cmdinstead ofclaude.ps1.In PowerShell, the resulting command becomes
& 'C:\Users\...\claude.cmd', which may fail or behave differently from runningclaudebare — letting PowerShell resolve it natively toclaude.ps1.Root Cause
In the bundled
extension.js, themme()function calls:On Windows, npm's
whichpackage iteratesPATHEXTextensions. TypicalPATHEXT:.PS1is absent, sowhichnever considersclaude.ps1. Ifclaude.cmdexists anywhere inPATH, it wins.The result is passed to
ume():If
tis a path (the.cmdfile), the fallback is never reached — PowerShell gets an explicit.cmdpath instead of letting it resolveclaudenatively.Expected Behavior
When the shell type is
powershell, the command should let PowerShell resolveclaudeon its own (which correctly finds.ps1files inPATH), either by:which()resolution for PowerShell on Windows and passing bare"claude", orwhich()also consider.ps1when the target shell is PowerShellReproduction
claudeCode.useTerminal: truein VS Code settingsclaude.cmdandclaude.ps1both inPATH(e.g.,%USERPROFILE%\bin)Ctrl+Escape& 'C:\Users\...\claude.cmd'instead of resolving toclaude.ps1