fix(claude-code-mcp): resolve venv interpreter in the Windows Scripts/ layout (#1758, 3a)#2066
Open
eldar702 wants to merge 1 commit into
Open
Conversation
…yout run_mcp.sh's resolve_py() probed only <venv>/bin/python and <venv>/bin/python.exe. A standard Windows CPython venv (python.org installer, Windows Store Python, `py -m venv`) puts the interpreter at <venv>/Scripts/python.exe, so resolve_py returned empty, the launcher fell through to venv re-creation, and re-creation failed whenever python/python3 were not on the spawning process's PATH (issue vectorize-io#1758, 3a). Add a Scripts/ elif branch and update the now-misleading "venv create failed" message to mention both layouts. POSIX behaviour is unchanged. Adds a hermetic pytest that invokes the real bash resolve_py against a fabricated venv tree: RED on the Scripts/ layout before this change, plus a bin/ regression guard for the POSIX path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
hindsight-integrations/claude-code/scripts/run_mcp.shresolves the plugin venv interpreter viaresolve_py(), which only probes${VENV}/bin/pythonand${VENV}/bin/python.exe. A standard Windows CPython venv — produced by the python.org installer, the Windows Store Python, andpy -m venv— puts the interpreter at${VENV}/Scripts/python.exe, never underbin/.So on the common Windows setup
resolve_pyreturns an empty$PY, the launcher falls through to venv re-creation, and re-creation then fails wheneverpython/python3aren't on the spawning process's PATH (frequent when Claude Code's VS Code extension host spawns the server) → "MCP server never starts, no useful error".This is sub-item 3a of #1758. The prior fix (#1564/#1565) only added the msys2/mingw
bin/python.exelayout; this composes cleanly with it.Fix (
scripts/run_mcp.sh)elifbranch toresolve_py()for the${VENV}/Scripts/python.exelayout (with the matchingScripts/pip.exe).venv create failed: no python interpreter at ${VENV}/bin/message to also mention${VENV}/Scripts/.POSIX behaviour is unchanged — the new branch only matches Windows-layout venvs, and the existing
bin/branches still take precedence.Test (RED-first)
New
tests/test_run_mcp.pyinvokes the real bashresolve_pyfunction (extracted from the script so none of its top-level side effects run) against a fabricated venv tree:test_windows_scripts_layout_is_resolved— venv hasScripts/python.exeand nobin/. RED onmain(resolve_pyreturns empty$PY), GREEN after theelif.test_posix_bin_layout_is_resolved— regression guard asserting the POSIXbin/pythonpath still wins.Verification
Scope: 2 files, +105/-1, no new dependencies, scoped to 3a only.
🤖 AI-assistance: drafted with Claude (Opus 4.8), reviewed for correctness