Skip to content

Windows: bare-name user-tool spawns resolve in the cwd before PATH; turn off the current-folder lookup at process start (release blocker, removes the native-Windows preview) #1911

Closed

Description

@amrmelsayed

Scope revised by the owner, 2026-11-20. The fix below ("route every site through the host resolver") is superseded. Measured on native Windows: setting NoDefaultCurrentDirectoryInExePath in the process turns off the current-folder lookup for every launch form Codev uses, so the hole is closed by one startup module imported first in each Codev entry point, with no call-site changes. Every terminal Tower opens gets the same variable, human shell tabs included (owner decision, option A): in cmd.exe a program in the current folder then runs only as . ame. Landed in PR #1948. The guard test, the planted-git.exe Windows test and the removal of the preview wording stay in scope. The call-site conversion and the commandExists unification are deferred as hygiene, not needed to close the hole. The plan is codev/plans/1911-windows-bare-name-user-tool-sp.md. The original text is kept below for the record.

Problem

On Windows a program started by bare name is looked up in the current directory before PATH (libuv for Node spawns, cmd.exe for execSync strings). Codev runs many commands with a builder worktree or a freshly cloned repository as the current directory, so a git.exe, gh.exe, npm.cmd or node.exe committed to that repository would run under Codev instead of the real tool.

Spec 1658 (PR #1859) fixed the system programs: powershell.exe, taskkill and cmd.exe now run by full System32 path. The user tools are not fixed. Native Windows ships as a preview in README and DEPENDENCIES.md for exactly this reason (plan Amendment 4), and this issue removes the preview wording when it lands.

Architect ruling (2026-10-23): a Windows release blocker. Full native Windows support is not announced until this is merged.

Fix

Route every bare-name user-tool spawn through the host resolver so lookup is PATH-only and never the cwd:

  • spawnableOnHost / findOnHostPath in packages/codev/src/lib/host-executable.ts (the shared remainder of the former shell-launch module after Spec 1658 Amendment 3), backed by the @cluesmith/codev-sdk/node/executable resolver, which searches PATH (with PATHEXT and .cmd shim handling) and never the cwd.
  • execSync("git …") string sites become argv spawns through the same path; no shell string for a user tool.
  • Unify commandExists on the shell-free resolver on both platforms (Spec 1658 review item A2.9: three which forms exist today, including doctor.ts building a which ${cmd} string). One implementation, no shell.

No behaviour change on POSIX beyond dropping the shell for these lookups.

Inventory (review of Spec 1658, "Known gap", at head 4752375; re-grep before starting)

User tools, 36 sites:

  • agent-farm/commands/self-refresh.ts: 484 execFileSync(git)
  • agent-farm/commands/team.ts: 26 execSync(git …)
  • agent-farm/utils/config.ts: 43 execSync(git …)
  • agent-farm/utils/worktree-write-guard.ts: 151 execSync(git …)
  • commands/consult/index.ts: 1639, 1640, 1808, 1825, 1840, 1845, 1950, 2344, 2377 execFileSync(git); 2074, 2125, 2240 execSync(git …)
  • commands/doctor.ts: 1104 spawnSync(git)
  • commands/init.ts: 176 execSync(git …), 192 execSync(codev …)
  • commands/porch/artifacts.ts: 390, 411, 424, 455 execFileSync(git)
  • commands/update.ts: 429 spawn(claude)
  • lib/default-branch.ts: 15 execSync(git …)
  • lib/github.ts: 288 execFile(gh)
  • lib/gitignore.ts: 168, 218 spawnSync(git)
  • lib/governance-bootstrap.ts: 254, 275 execFileSync(git)
  • lib/protocol-drift-audit.ts: 200 spawnSync(npm)
  • lib/tree-snapshot.ts: 91, 107, 125, 184, 359 execFileSync(git)

All paths under packages/codev/src/. Call sites that take the command from a variable (harness commands via ptyCommand / spawnOnHost) are already covered and not listed.

POSIX-only tools (ps, pgrep, tail, which, sysctl, du, command -v; sites listed in the review) are not in scope to change, but the follow-up confirms each is unreachable on Windows.

Verification

  • A static check (test or script) that no non-test source under packages/codev/src spawns a bare user-tool name through child_process directly; the allowed path is the host resolver. Wire it into the unit CI job like the Spec 1658 /tmp residue check.
  • Windows dispatch green; a Windows test that plants a fake git.exe in a worktree-shaped cwd and shows Codev still runs the PATH git.
  • Remove the preview wording from README and both DEPENDENCIES.md copies (byte-identical) in the same PR.

Out of scope

The remaining single-site isWindows() forks (Spec 1658 plan A2.5) and the IDE-server capability (#1890).

Follows Spec 1658 / PR #1859. Label area/cross-cutting: the sites span agent-farm, consult, porch, doctor, init, update and lib.

Activity

  1. amrmelsayed commented on Nov 20, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).

  2. added 9 commits that reference this issue on Nov 20, 2026
  3. changed the title [-]Windows: bare-name user-tool spawns resolve in the cwd before PATH; route all 36 sites through the host resolver (release blocker, removes the native-Windows preview)[/-] [+]Windows: bare-name user-tool spawns resolve in the cwd before PATH; turn off the current-folder lookup at process start (release blocker, removes the native-Windows preview)[/+] on Nov 22, 2026
  4. added 7 commits that reference this issue on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cross-cuttingTouches multiple areas — needs coordinated handling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions