[Bug] claude-vscode.terminal.open on Windows with PowerShell picks .cmd over .ps1 via PATHEXT

Open 💬 0 comments Opened Jun 15, 2026 by RayeLouis

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:

  1. Skipping which() resolution for PowerShell on Windows and passing bare "claude", or
  2. Making which() also consider .ps1 when the target shell is PowerShell

Reproduction

  • OS: Windows 11
  • Extension version: 2.1.177
  • Steps:
  1. Set claudeCode.useTerminal: true in VS Code settings
  2. Have claude.cmd and claude.ps1 both in PATH (e.g., %USERPROFILE%\bin)
  3. Click "Claude Code: Open in Terminal" or press Ctrl+Escape
  4. The terminal runs & 'C:\Users\...\claude.cmd' instead of resolving to claude.ps1

View original on GitHub ↗