Skip to content

Fix agent command resolution on Windows#44

Open
RasmusHochreuter wants to merge 1 commit intocomputerlovetech:mainfrom
RasmusHochreuter:fix/windows-agent-command-resolution
Open

Fix agent command resolution on Windows#44
RasmusHochreuter wants to merge 1 commit intocomputerlovetech:mainfrom
RasmusHochreuter:fix/windows-agent-command-resolution

Conversation

@RasmusHochreuter
Copy link
Copy Markdown

Summary

  • On Windows, subprocess.Popen cannot find executables by bare name (e.g. claude) without the file extension (.exe). This causes ralph run to crash with FileNotFoundError when the agent field in RALPH.md uses a bare command name like claude -p --dangerously-skip-permissions.
  • Uses shutil.which() to resolve the executable path before passing it to subprocess.Popen. This works cross-platform — finding claude on Unix and claude.exe on Windows.
  • No behavior change on macOS/Linux where bare names already resolve correctly.

Reproduction

On Windows with Claude Code installed:

# RALPH.md frontmatter
agent: claude -p --dangerously-skip-permissions
$ ralph run .
Run crashed: Agent command not found: 'claude -p --dangerously-skip-permissions'
FileNotFoundError: [WinError 2] The system cannot find the file specified

Fix

Added shutil.which() resolution in _run_agent_phase() (engine.py) right after shlex.split() parses the agent command string. If the executable is found on PATH, the resolved absolute path replaces the bare name. If not found, the original value is preserved so the existing FileNotFoundError handling still produces a clear error message.

Test plan

  • Verified fix resolves the crash on Windows 11
  • Confirm no regression on macOS/Linux (bare names still work)
  • Existing tests pass (test_engine.py agent-related tests)

🤖 Generated with Claude Code

On Windows, subprocess.Popen cannot find executables by bare name
(e.g. "claude") without the file extension. Use shutil.which() to
resolve the executable path before passing it to subprocess, which
works cross-platform — finding "claude" on Unix and "claude.exe" on
Windows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant