Skip to content

configure crashes on Windows with FileNotFoundError when shelling out to npm-installed CLIs (claude/npm) — bare command name not resolved via PATHEXT #247

Description

@adrian-tompkins

Disclaimer: this issue was investigated and drafted with the assistance of an AI coding agent.

Summary

On Windows, ucode configure crashes with FileNotFoundError: [WinError 2] The system cannot find the file specified when it shells out to claude (or npm) via subprocess.run([...]). The subprocess call uses a bare command name ("claude", "npm"), which resolves to claude.cmd / npm.cmd when those tools are installed via npm. Python's subprocess.run (without shell=True) calls CreateProcess, which only appends .exe and does not honor PATHEXT — so .cmd/.ps1 shims are never found, even when where claude / where npm succeed in the shell.

Additionally, _register_web_search_mcp in claude.py only catches RuntimeError around remove_claude_mcp_server, so the FileNotFoundError propagates and crashes the whole configure run instead of being treated as best-effort cleanup.

Environment

  • OS: Windows (cmd.exe)
  • ucode installed via uv tool install
  • Python: uv-managed CPython 3.14.6 (bundled with the ucode tool)
  • claude and codex installed via npm install -g (i.e. present as claude.cmd / codex.cmd)
  • Databricks CLI >= v1.0.0

Affected call sites

  • ucode/mcp.py:140subprocess.run(["claude", "mcp", "remove", name, "-s", scope], ...)
  • ucode/agents/__init__.py:217subprocess.run(["npm", "install", "-g", package], ...)
  • ucode/agents/claude.py:277 / 362_register_web_search_mcp only guards against RuntimeError, not FileNotFoundError

Repro

  1. On Windows, install claude and codex via npm install -g (so they exist as .cmd).
  2. Run ucode configure --agents codex,claude.
  3. Auth completes, then it crashes at remove_claude_mcp_server with FileNotFoundError: [WinError 2].

(Same class of failure hits the npm install -g path in install_tool_binary when the agent binary isn't already present.)

Traceback

...
File "ucode\mcp.py", line 140, in remove_claude_mcp_server
  subprocess.run(["claude", "mcp", "remove", name, "-s", scope], ...)
...
FileNotFoundError: [WinError 2] The system cannot find the file specified

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions