Repository navigation
fix(cli): parse where output on Windows to prefer .cmd/.exe wrappers - #969
Merged
diegosouzapw merged 2 commits intoApr 3, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
The locateCommand function returned the bare command name instead of parsing the where output. On Windows, npm global installs create both a Unix shell script (no extension) and a .cmd wrapper. where returns both, and the bare name resolves to the Unix script first, causing healthcheck failures for OpenClaw and OpenCode. Fix: parse where output and prefer paths with Windows executable extensions (.cmd, .exe, .bat, .com). Related: cheaper-inference#935, cheaper-inference#863
Contributor
There was a problem hiding this comment.
Code Review
This pull request improves command location on Windows by parsing multiple results from the where command and prioritizing executable extensions like .cmd or .exe. Review feedback identifies a potential undefined return value if the command output is empty, a command injection vulnerability from unsafe paths in the environment, and the need to normalize MSYS2-style paths.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
whereoutput on Windows to prefer.cmd/.exewrappers instead of returning the bare command nameRoot Cause
The fix from #863/#935 added
PATHEXTandComSpecto theminimalEnvincheckRunnable, which was necessary but not sufficient. The real bug is upstream inlocateCommand— it runswhere <command>on Windows but ignores the output, returningcommandPath: command(bare name like"opencode").On Windows, npm global installs create two files:
opencode— Unix shell script (#!/bin/sh), not runnable on Windowsopencode.cmd— Windows batch wrapper, the correct executablewhere opencodereturns both. Since the code never parsed the output, the healthcheck tried to run the bare name, which resolved to the Unix script first →healthcheck_failed.Claude Code (
where claude→ singleclaude.exe) was unaffected.Fix
Parse
whereoutput line-by-line and prefer paths with Windows executable extensions (.cmd,.exe,.bat,.com). Falls back to the first line if none match.Validation
where opencodereturns two lines on Windows; fix selects.cmdwhere claudereturns single.exe; no change in behaviorauth-clear-provider-routes.test.mjs— missingyazl) is unrelated to this changeRelated
locateCommandignoreswhereoutput #968