Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(core): try PATHEXT before the bare name, not after
Erik Zwep4718d5d971e3
diff --git a/src/core/exec-path.test.ts b/src/core/exec-path.test.tsindex 5d679408c..ae06756e8 100644--- a/src/core/exec-path.test.ts+++ b/src/core/exec-path.test.ts@@ -10,24 +10,25 @@ describe('executableCandidates', () => {expect(executableCandidates('gh', 'linux', '.EXE')).toEqual(['gh'])})- it('appends PATHEXT on win32, bare name first', () => {+ it('appends PATHEXT on win32, extensions first and the bare name last', () => {// The regression this closes: `gh` on Windows is `gh.exe`, so a bare-name-only walk found- // nothing and every caller fell through to its POSIX fallbacks.+ // nothing and every caller fell through to its POSIX fallbacks. The ORDER is load-bearing too+ // — see the shim test below.expect(executableCandidates('gh', 'win32', '.COM;.EXE;.CMD')).toEqual([- 'gh','gh.COM','gh.EXE',- 'gh.CMD'+ 'gh.CMD',+ 'gh'])})it('falls back to the stock PATHEXT when the variable is missing or empty', () => {expect(executableCandidates('ssh', 'win32', undefined)).toEqual([- 'ssh','ssh.COM','ssh.EXE','ssh.BAT',- 'ssh.CMD'+ 'ssh.CMD',+ 'ssh'])expect(executableCandidates('ssh', 'win32', '')).toEqual(executableCandidates('ssh', 'win32', undefined)@@ -36,9 +37,9 @@ describe('executableCandidates', () => {it('tolerates whitespace and empty entries in PATHEXT', () => {expect(executableCandidates('gh', 'win32', ' .EXE ; ; .CMD ')).toEqual([- 'gh','gh.EXE',- 'gh.CMD'+ 'gh.CMD',+ 'gh'])})@@ -122,11 +123,24 @@ describe('findInPathString (real filesystem)', () => {expectPath(findInPathString('nt-cmd-only', dir), path.join(dir, 'nt-cmd-only.cmd'))})- it('prefers an extensionless file when one exists, and still finds a name given in full', () => {- writeBin('nt-both')- writeBin('nt-both.exe')- expectPath(findInPathString('nt-both', dir), path.join(dir, 'nt-both'))- expectPath(findInPathString('nt-both.exe', dir), path.join(dir, 'nt-both.exe'))+ it('prefers the PATHEXT match over an extensionless shim in the same directory', () => {+ // Exactly what npm lays down for a global CLI on Windows: `<name>` is a POSIX shell shim for+ // Git Bash and `<name>.cmd` is the one cmd/CreateProcess can actually run. Preferring the+ // bare name here returns a file that exists and cannot be spawned.+ writeBin('nt-shim')+ writeBin('nt-shim.cmd')+ expectPath(findInPathString('nt-shim', dir), path.join(dir, 'nt-shim.cmd'))+ })++ it('falls back to an extensionless file when nothing matches PATHEXT', () => {+ // An extensionless PE is executable, so it stays a last resort rather than being ignored.+ writeBin('nt-bare-only')+ expectPath(findInPathString('nt-bare-only', dir), path.join(dir, 'nt-bare-only'))+ })++ it('still finds a name given in full', () => {+ writeBin('nt-full.exe')+ expectPath(findInPathString('nt-full.exe', dir), path.join(dir, 'nt-full.exe'))})})})diff --git a/src/core/exec-path.ts b/src/core/exec-path.tsindex c1f2e8c12..a678d8890 100644--- a/src/core/exec-path.ts+++ b/src/core/exec-path.ts@@ -80,9 +80,13 @@ const DEFAULT_PATHEXT = '.COM;.EXE;.BAT;.CMD'* `null` for every lookup on Windows — and, downstream, no `gh`, no `ssh`, and a claude* capability probe that never ran.*- * The bare name stays FIRST so an extensionless executable still wins where one exists, and a- * `bin` that already carries a PATHEXT suffix is returned untouched rather than growing a second- * one (`gh.exe.EXE`).+ * PATHEXT entries come FIRST and the bare name LAST, which is the order Windows itself resolves in+ * — and the order matters more than it looks. npm installs a global CLI as BOTH `<name>` (a POSIX+ * shell shim, for Git Bash) and `<name>.cmd` (for cmd) in the same directory. Trying the bare name+ * first hands back the shim, which `CreateProcess` cannot run: the spawn fails with a file that+ * plainly exists. The bare name is kept as a last resort because an extensionless PE is executable,+ * just not the thing to prefer. A `bin` that already carries a PATHEXT suffix is returned untouched+ * rather than growing a second one (`gh.exe.EXE`).** The extension is appended with PATHEXT's OWN casing, which is conventionally upper case — so a* hit on `gh.exe` comes back as `...\gh.EXE`. That is the same file (Windows paths are@@ -105,7 +109,7 @@ export function executableCandidates(.filter(Boolean)const lower = bin.toLowerCase()if (exts.some((e) => lower.endsWith(e.toLowerCase()))) return [bin]- return [bin, ...exts.map((e) => bin + e)]+ return [...exts.map((e) => bin + e), bin]}/** Strip the quotes Windows tolerates around a PATH entry ("C:\Program Files\..."). `where.exe`