Skip to content

fix(env): put the interpreter's scripts dir on the spawned PATH - #24510

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/augmented-path-scripts-dir
Oct 27, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/augmented-path-scripts-dir

Conversation

@JLargent42

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the Windows desktop build, sessions find the uv / uvx that ship with the backend, so stdio MCP servers launched through uvx start without a user-installed uv.

The kiro-cli child gets its PATH from augmented_path(), which adds the running interpreter's folder last. The Windows desktop backend is a python-build-standalone tree: python.exe sits at the tree root and pip puts console scripts, including uv.exe / uvx.exe, in kirocrew-backend\Scripts\. That folder is never on the child's PATH, so shutil.which("uvx", path=augmented_path(PATH)) returns None and a uvx-launched MCP server fails with connection closed: initialize response.

Why it matters

Every Windows desktop user without their own uv install loses every MCP server that starts through uvx, including the registry pypi entries, and the error does not say why.

Not a goal

  • Changing how Kiro Crew itself finds uv (resolve_uv() already uses uv.find_uv_bin()).
  • Changing the Electron launcher in website/electron/.
  • Reordering PATH: the interpreter folders stay the last-resort entries.

What changed (motivation → approach → change)

The interpreter's folder and its console-scripts folder are one folder in a venv and on POSIX, but two folders on the Windows desktop backend. augmented_path() now appends both, in that order, still after base_path. The scripts folder comes from sysconfig.get_path("scripts"), read once when env.py loads, and is skipped when it is the same folder or not absolute. It is read once because sysconfig expands ~ in its result, and augmented_path callers that pin a specific home must not pick up the process home. The docstring describes both layouts.

Backwards compatibility

Compatible: in a venv the scripts folder is the interpreter folder and is not added twice, so the PATH is unchanged; elsewhere one more folder is appended after every existing entry, so no name resolves differently except one found nowhere else.

Removes nothing: no entry, key, function or accepted input is removed.

Tests

In test/test_env.py (TestAugmentedPath):

  • test_finds_a_console_script_beside_a_root_level_interpreter: lays out the desktop tree (interpreter at the root, uvx in Scripts) on disk; the last two entries are the root and Scripts, and shutil.which("uvx") finds it. It uses .exe names on Windows.
  • test_a_scripts_dir_that_is_the_interpreter_dir_is_listed_once: a venv's shared folder is listed once and stays last.
  • test_appends_running_interpreter_bin_dir_last pins the scripts folder, so the existing order check keeps its meaning.

The layout test reports every executable outside tmp_path as absent, so a uvx already installed on the host cannot answer the lookup.

Proof: not provable -- other: prove.py's throwaway checkout errored at collection on the sibling PR; a manual revert of the augmented_path change turns test_finds_a_console_script_beside_a_root_level_interpreter red and the fix turns it green (head 6aba955)

Determinism: the 14 TestAugmentedPath node ids ran green 20 times at -n0 and 10 times at -n 2 --dist loadgroup beside test/test_env_homebrew_keg_node.py; the whole of test/test_env.py ran green in shuffled order (seed 27350).

Manual verification

Not run on a Windows desktop install. The test reproduces the reported layout and lookup (shutil.which("uvx", path=augmented_path(...))). Local gates green on Linux: 552 related tests (test_env.py, ACP spawn/resolution, MCP gateway PATH, Node toolchain, facade guards), black, isort, flake8, mypy, semgrep, flake-pattern ratchet.

Related Issues

Closes #24459

Sibling sweep

Swept: git grep -nE "Path(sys.executable).parent" -- src/
Sibling: src/kiro_crew/env.py:942 -- changed here
Sibling: src/kiro_crew/platform/wheel_engine_layout.py:132 -- not affected -- classifies the interpreter tree (also line 196), it does not build a search path
Sibling: src/kiro_crew/service/macos.py:280 -- not affected -- macOS only, where scripts sit beside the interpreter in bin/

Pattern harvest

Not generalizable: one search-path builder assumed the interpreter folder holds the console scripts; it is the only place that builds the spawned child's fallback PATH.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners October 26, 2026 17:54
@JLargent42
JLargent42 requested a review from mbriones98 October 26, 2026 17:54
@JLargent42

JLargent42 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor Author

Local pre-push review note (not a CI lane disposition): the local GPT reviewer flagged that the new layout test could pick up a host-installed uvx from an earlier PATH folder such as ~/.local/bin. Fixed before the first push: the test reports every executable outside tmp_path as absent (the os.access filter test_finds_an_adapter_installed_under_the_dotted_n_prefix already uses). With an executable uvx in a fake home .local/bin, the test fails without the filter and passes with it; reverting the production change still turns it red.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of c90943b0410222f40e3f282903c6a874530ab60a — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the fix adds one folder at the end of the fallback PATH, reads it from sysconfig (standard Python behaviour), and a revert removes it cleanly.

Notes

  • The Windows desktop path is only covered by a test that rebuilds its folder layout. A smoke run of shutil.which("uvx", path=augmented_path(...)) on a real desktop install would turn "Not run on a Windows desktop install" into evidence.

[DESIGN-REVIEWED] c90943b

Description read

[DESCRIPTION-READ] 544c48e775a96b6e09b6ff882b07564b7e96c844e18f5c868023fa47fe1a047d

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c90943b0410222f40e3f282903c6a874530ab60a — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. This is a one-line mechanism fix with an issue and a failing-on-base test behind it, and no other place in src/ builds this search path.

What this change ships

Inventory (4 items) — 4 justified

Intent: Windows desktop users can start uvx-launched MCP servers using the uv bundled with the backend. FIX.

  1. Spawned sessions on the Windows desktop build now find the bundled uv/uvx (and the kirocrew wrappers) in kirocrew-backend\Scripts\. — justified
  2. In a venv or POSIX layout, where the scripts folder is the interpreter folder, the child's PATH is unchanged (listed once). — justified
  3. The scripts folder is read once, when env.py loads, so callers that pin a home don't pick up the process home through expanduser. — justified
  4. The augmented_path docstring now describes both layouts. — justified

[FIRST-PRINCIPLES-REVIEWED] c90943b

Description read

[DESCRIPTION-READ] 546ecee38e3226119cc19776475da131823f856b3d26a93bbc53671ecae3b212

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c90943b0410222f40e3f282903c6a874530ab60a touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of c90943b0410222f40e3f282903c6a874530ab60a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c90943b

False positive or not applicable? A repository writer can comment:
/ai-review override gpt c90943b0410222f40e3f282903c6a874530ab60a false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed c90943b0410222f40e3f282903c6a874530ab60a — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] c90943b

Verdict parsed from the review's SHA-scoped output markers for commit c90943b0410222f40e3f282903c6a874530ab60a.

False positive or not applicable? A repository writer can comment:
/ai-review override fable c90943b0410222f40e3f282903c6a874530ab60a false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 26, 2026
@JLargent42
JLargent42 force-pushed the fix/augmented-path-scripts-dir branch from 6aba955 to b323e53 Compare October 26, 2026 18:04
@JLargent42

Copy link
Copy Markdown
Contributor Author
  • span=6df39e78b5d2 test_prepends_extra_dirs assumes the interpreter folder is the last PATH entry

fixed in b323e53: test_prepends_extra_dirs asserts the tail equals env_mod._interpreter_script_dirs() and that /usr/bin sits right before it, so it holds whether the interpreter's scripts folder is the same folder (venv) or a separate one (the no-venv setup-python interpreter on the Windows runner).
Reproduced on Linux by pinning _INTERPRETER_SCRIPTS_DIR to a separate folder: the old assertions fail, the new ones pass. Swept 14 related test files (653 tests) under that same split layout; no other test assumed the old tail.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 26, 2026
@JLargent42

Copy link
Copy Markdown
Contributor Author

CI note: Backend Tests (Windows) (4) on b323e53 fails only test/test_telegram_dispatcher.py::TestABusyReplyCarriesItsContext (2 cases, assert [] == ["telegram_reply_parent"]). That is main breakage tracked in #24514 (fix in #24531); this PR does not touch the Telegram dispatcher. Not re-running; waiting for #24531 to merge.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 26, 2026
@JLargent42
JLargent42 force-pushed the fix/augmented-path-scripts-dir branch from b323e53 to 9613088 Compare October 26, 2026 23:03
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main (5285bc2) with maintainer approval to pick up #24531 (main-red #24514); no code change.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 26, 2026
@JLargent42

Copy link
Copy Markdown
Contributor Author

CI note: Backend Tests (Windows) (6) on 9613088 fails only test/test_slack_team_id_env.py::TestSpawnEnv (6 cases, FileNotFoundError: [WinError 2] from the real Windows CreateProcess of the mocked /usr/bin/kiro-cli). That is main breakage from #22380, tracked in #24612 with a fix in #24613; it fails the same way on PRs that touch no Python. Not re-running and not rebasing; waiting for #24613.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@JLargent42
JLargent42 force-pushed the fix/augmented-path-scripts-dir branch from 9613088 to c90943b Compare October 27, 2026 16:34
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main (0a864a5) to pick up the Windows shard 6 fix #24609 (#24612); no code change.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 27, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 27, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 27, 2026 22:08

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tier 1 auto-approve: fix (2 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: a bug fix that appends the interpreter's sysconfig scripts directory after its own directory on the spawned PATH, so bundled console scripts resolve on the Windows desktop layout.

@KiroCrewCaptain
KiroCrewCaptain merged commit d08f7c5 into main Oct 27, 2026
159 of 163 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/augmented-path-scripts-dir branch October 27, 2026 22:09
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows desktop: kiro-cli sessions can't find the bundled uv/uvx because augmented_path omits the backend's Scripts\ folder

2 participants