Repository navigation
Resolve npm .cmd-shim backends on Windows - #2
Merged
rodion-m merged 4 commits intoOct 5, 2026
Merged
Conversation
The backend contract resolves CLI paths with Python's shutil.which. Under native Windows Python that walks PATHEXT and returns the `foo.CMD` sibling spelled with backslashes. The value is then consumed by bash, which can neither `command -v` that path nor exec-test it: npm writes the .cmd shim without the executable bit, and the launcher bash can use is the extensionless name on its own PATH. Every npm-installed backend was therefore rejected with a false "backend CLI not found", which also masked the real backend error. Fall back to the extensionless basename when the resolved value looks like a path and is unusable. A bare name that resolves to nothing still fails where it did before. Fixes CodeAlive-AI#1 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Resolve version conflicts in .claude-plugin/*.json by taking upstream 2.0.0-beta.1; the 1.3.5 bump from this branch is superseded. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Re-run smoke tests after a flaky ubuntu failure caused by interleaved writes to the fake backend argv log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
merged. thanks for contribution! |
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.
Fixes #1.
What was wrong
resolve_binary()usesshutil.which. Under native Windows Python that walksPATHEXTand returns the.CMDsibling with backslashes:The resolved value is consumed by bash in
backend_run.sh, and neither half of the existing check can accept it:command -vdoes not resolve an absolute backslash path, and[[ -x ]]is false because npm writes the.cmdshim without the executable bit.Result: every npm-installed backend (
codex,opencode,gemini) is rejected with a falsebackend CLI not found, and the real backend error stays hidden behind it.The change
This is option B from the issue — the fallback lives in the shell layer that actually consumes the value, so
resolve_binaryand its Python-side callers keep their current contract. Happy to move it intoresolve_binaryinstead if you prefer option A; the test does not care which layer fixes it.When
$BINis unusable and looks like a resolved path, retry with the extensionless basename. A bare name that resolves to nothing fails exactly where it did before, so a genuine misconfiguration is still reported.Test
New section in
scripts/tests/run.sh, built on the existing fakes: ashimcodex+ non-executableshimcodex.cmdpair, withPORCH_BIN_CODEXpointing at the backslash-spelled.CMDpath.The condition is reproducible on any platform — on Linux that path is simply an unresolvable filename — so the regression is covered by the existing
ubuntu-latest/macos-latestjob that runsrun.sh, without needing the Windows job to install a backend CLI.Verified in a Linux environment:
main)windows .cmd path falls back to extensionless launcherandwindows .cmd path is not reported missingboth FAIL with the reported error;missing bare binary still failsstill passesscripts/tests/platform_test.pyalso passes (20 tests, 4 skipped).Note on the Windows CI gap
porch-smoke.ymldoes coverwindows-latest, but no backend CLI is installed there, so a.cmdshim is never resolved and this class of bug is invisible to the matrix. The test added here closes that without changing the workflow. If you would rather also exercise it natively on Windows, that would need a shim fixture plus a Windows-enabled slice ofrun.sh— happy to do that in a follow-up if it is useful.🤖 Generated with Claude Code