Terminal launcher os error 2 blocks required git/pytest finalization commands #556

Closed
opened 2026-07-08 14:51:55 -05:00 by jcwalker3 · 3 comments
Owner

Problem

A Gitea-Tools author/finalizer session for PR #545 / Issue #531 could not execute any required shell command because run_terminal_command failed consistently with:

Terminal error: IO Error: No such file or directory (os error 2)

The failure happened for all command forms tested, including normal shell commands, absolute binaries, clean environment invocations, Python subprocess wrappers, and subagent terminal calls with explicit cwd.

Impact

PR #545 finalization is blocked because the author session cannot run required commands:

  • git fetch
  • git status
  • git rm -f test_mcp_conn.py
  • git diff --check prgs/master...HEAD
  • targeted pytest
  • git add
  • git commit
  • git push

The remote PR #545 head remains unchanged at:

c64809134fec7d2e2cc4bc312ba5b71dfc91b324

The local intended worktree is:

/Users/jasonwalker/Development/Gitea-Tools/branches/fix-issue-531-mcp-eof-defect

Correct Session Behavior Observed

The LLM followed the required BLOCKED + DIAGNOSE rule:

  • stopped before claiming success
  • did not mutate the root checkout
  • did not use temp scripts, direct imports, MCP internals, direct API fallback, in-memory state restoration, or bypasses
  • did not commit or push
  • did not post a misleading PR update
  • reported exact failure evidence
  • confirmed the PR remote head did not change

Evidence

Every terminal attempt failed with:

Tool run_terminal_command failed: Terminal error: IO Error: No such file or directory (os error 2)

The failure persisted across:

  • cd /full/worktree && ...
  • git -C /full/worktree ...
  • PWD=/tmp /usr/bin/env -i ...
  • /bin/zsh -c ...
  • /usr/bin/git
  • /usr/bin/python3
  • Python subprocess wrappers
  • simple pwd / echo
  • subagent terminal execution

Expected Behavior

The terminal launcher should be able to execute commands in an explicit branches/ worktree path, or fail with a clearer diagnostic that identifies the missing executable/path/cwd component.

Acceptance Criteria

  • Determine why run_terminal_command returns os error 2 for all commands in this session/environment.
  • Add diagnostic output that distinguishes missing shell, missing cwd, missing executable, missing runtime wrapper, or session launcher failure.
  • Confirm commands work from:
    • root checkout read-only inventory context
    • isolated branches/ author worktree
    • explicit git -C <worktree> invocation
  • Add a preflight/check that detects terminal launcher failure before author/reviewer workflows attempt git/pytest finalization.
  • Ensure the workflow returns BLOCKED + DIAGNOSE instead of attempting unsafe fallback when terminal execution is required but unavailable.
  • After this issue is fixed, PR #545 can be retried from the isolated author worktree and finalized normally.

Related

  • PR #545 / Issue #531 remains blocked until shell commands work.
  • Issue #552 defines the general BLOCKED + DIAGNOSE rule.
  • This issue is the concrete terminal-launcher failure that triggered that rule.
## Problem A Gitea-Tools author/finalizer session for PR #545 / Issue #531 could not execute any required shell command because `run_terminal_command` failed consistently with: `Terminal error: IO Error: No such file or directory (os error 2)` The failure happened for all command forms tested, including normal shell commands, absolute binaries, clean environment invocations, Python subprocess wrappers, and subagent terminal calls with explicit cwd. ## Impact PR #545 finalization is blocked because the author session cannot run required commands: * `git fetch` * `git status` * `git rm -f test_mcp_conn.py` * `git diff --check prgs/master...HEAD` * targeted `pytest` * `git add` * `git commit` * `git push` The remote PR #545 head remains unchanged at: `c64809134fec7d2e2cc4bc312ba5b71dfc91b324` The local intended worktree is: `/Users/jasonwalker/Development/Gitea-Tools/branches/fix-issue-531-mcp-eof-defect` ## Correct Session Behavior Observed The LLM followed the required `BLOCKED + DIAGNOSE` rule: * stopped before claiming success * did not mutate the root checkout * did not use temp scripts, direct imports, MCP internals, direct API fallback, in-memory state restoration, or bypasses * did not commit or push * did not post a misleading PR update * reported exact failure evidence * confirmed the PR remote head did not change ## Evidence Every terminal attempt failed with: `Tool run_terminal_command failed: Terminal error: IO Error: No such file or directory (os error 2)` The failure persisted across: * `cd /full/worktree && ...` * `git -C /full/worktree ...` * `PWD=/tmp /usr/bin/env -i ...` * `/bin/zsh -c ...` * `/usr/bin/git` * `/usr/bin/python3` * Python subprocess wrappers * simple `pwd` / `echo` * subagent terminal execution ## Expected Behavior The terminal launcher should be able to execute commands in an explicit `branches/` worktree path, or fail with a clearer diagnostic that identifies the missing executable/path/cwd component. ## Acceptance Criteria * Determine why `run_terminal_command` returns `os error 2` for all commands in this session/environment. * Add diagnostic output that distinguishes missing shell, missing cwd, missing executable, missing runtime wrapper, or session launcher failure. * Confirm commands work from: * root checkout read-only inventory context * isolated `branches/` author worktree * explicit `git -C <worktree>` invocation * Add a preflight/check that detects terminal launcher failure before author/reviewer workflows attempt git/pytest finalization. * Ensure the workflow returns `BLOCKED + DIAGNOSE` instead of attempting unsafe fallback when terminal execution is required but unavailable. * After this issue is fixed, PR #545 can be retried from the isolated author worktree and finalized normally. ## Related * PR #545 / Issue #531 remains blocked until shell commands work. * Issue #552 defines the general `BLOCKED + DIAGNOSE` rule. * This issue is the concrete terminal-launcher failure that triggered that rule.
Author
Owner

Duplicate search results (performed before creation)

Searched via gitea_list_issues (state=open + state=all, limit=50, remote=prgs, repo=Gitea-Tools) + targeted view_issue on #552 + list_issue_comments on #552.

Search terms used (per query + workflow):

  • run_terminal_command IO Error No such file or directory
  • Terminal error os error 2
  • broken terminal launcher
  • shell launcher cwd failure
  • PR #545 terminal blocked
  • command runner unavailable
  • BLOCKED + DIAGNOSE terminal
  • plus titles/bodies containing "terminal", "launcher", "run_terminal", "os error 2", "IO Error", PR 545 context, BLOCKED DIAGNOSE.

Results:

  • No exact match for this specific terminal launcher defect (os error 2 blocking git/pytest in author finalizer for PR #545).
  • Closest/related: #552 "Require BLOCKED + DIAGNOSE when LLM cannot perform required workflow step" (general rule; body mentions "broken terminal execution" and "Terminal command runner is broken" as examples, plus recent comments on similar blockers, but does not track this exact launcher failure + PR #545 evidence + acceptance criteria).
  • Other related: #531 (original), #544/#543 (MCP EOF), #546 (lease preflight), but none describe the run_terminal_command os error 2.

No duplicate created. New issue #556 created with full evidence.

See #552 for the general rule. This issue provides the concrete reproduction for the terminal launcher.

## Duplicate search results (performed before creation) Searched via `gitea_list_issues` (state=open + state=all, limit=50, remote=prgs, repo=Gitea-Tools) + targeted `view_issue` on #552 + `list_issue_comments` on #552. **Search terms used (per query + workflow):** - run_terminal_command IO Error No such file or directory - Terminal error os error 2 - broken terminal launcher - shell launcher cwd failure - PR #545 terminal blocked - command runner unavailable - BLOCKED + DIAGNOSE terminal - plus titles/bodies containing "terminal", "launcher", "run_terminal", "os error 2", "IO Error", PR 545 context, BLOCKED DIAGNOSE. **Results:** - No exact match for this specific terminal launcher defect (os error 2 blocking git/pytest in author finalizer for PR #545). - Closest/related: #552 "Require BLOCKED + DIAGNOSE when LLM cannot perform required workflow step" (general rule; body mentions "broken terminal execution" and "Terminal command runner is broken" as examples, plus recent comments on similar blockers, but does not track this exact launcher failure + PR #545 evidence + acceptance criteria). - Other related: #531 (original), #544/#543 (MCP EOF), #546 (lease preflight), but none describe the run_terminal_command os error 2. No duplicate created. New issue #556 created with full evidence. See #552 for the general rule. This issue provides the concrete reproduction for the terminal launcher.
jcwalker3 added the status:in-progress label 2026-07-08 14:53:46 -05:00
Author
Owner

Issue claim heartbeat

<!-- gitea-issue-claim-heartbeat:v1 --> **Issue claim heartbeat** - kind: claim - issue: #556 - branch: pending - phase: claimed - profile: prgs-author - pr: none - blocker: none - next_action: create worktree and begin implementation
jcwalker3 added the mcpgiteamutatingworkflowtracker labels 2026-07-08 14:54:02 -05:00
Author
Owner

Diagnosis Update (current session)

Failure still reproduces exactly as described in #556.

Every invocation of run_terminal_command (and monitor) fails with:
Tool run_terminal_command failed: Terminal error: IO Error: No such file or directory (os error 2)

Safe non-mutating tests attempted (all failed identically):

  • pwd
  • echo ok
  • /bin/echo ...
  • /usr/bin/python3 --version
  • git -C /full/path/to/worktree ...
  • ls /absolute/path
  • PWD=/tmp /usr/bin/env -i ... /bin/zsh -c 'cd /worktree && ...'
  • Python subprocess wrappers with os.chdir + subprocess
  • Commands targeting root and the exact worktree /Users/jasonwalker/Development/Gitea-Tools/branches/fix-issue-531-mcp-eof-defect
  • git --version absolute

list_dir and other FS tools work (e.g. list_dir on / and worktree succeeds, showing /bin/sh, /bin/zsh, /usr/bin/git, /usr/bin/python3 exist).

grep/read_file work for code inspection.

No shell command succeeds.

Likely cause classification:

  • Broken terminal launcher wrapper in the agent runtime (not a missing executable or PATH issue, since FS tools see the bins).
  • Stale/invalid cwd in the underlying shell process (ENOENT on spawn/chdir/getcwd). Likely from prior cd into a deleted nested worktree path (e.g. during earlier author worktree ops for PRs).
  • Not project worktree specific (fails even for simple pwd/echo).
  • Not permissions (list_dir works).
  • Agent/session process state corruption.

Repo-owned? No. The run_terminal_command tool is provided by the host agent platform (not implemented in Gitea-Tools source). No code change in this repo can fix the launcher. The project's code has shell spawn circuit-breaker handling (#258, #270 in gitea_mcp_server.py, native_mcp_preference.py), but the failure happens at the tool call layer before any project code runs.

Recovery steps attempted:

  • Various command forms, absolute paths, clean env, PWD override, python wrappers, subagents with cwd= param, monitor tool.
  • All same error.
  • Non-mutating FS inspection only (no root mutations, no edits to fix-issue-531 worktree yet).

BLOCKED + DIAGNOSE per #552 rule.

Recommended durable fix (operator / platform):

  1. Restart the current agent/LLM session or the host process to reset the shell wrapper's internal cwd to a valid dir (e.g. project root or /tmp).
  2. Add preflight in agent launcher: before spawning, verify getcwd() succeeds or chdir(/) as fallback; emit clear diagnostic like "launcher_cwd_invalid: <bad_path>" or "shell_spawn_failed: ENOENT cwd=<...> exec=<...>".
  3. Distinguish in errors: missing shell vs missing cwd vs missing exec vs wrapper bug.
  4. Update agent docs or this project's runbooks if needed.

No mutations occurred in this diagnosis pass (only reads, MCP calls for issue view, list, comments for context, grep for code mentions of shell spawn).

Single next action: Operator/platform restart of agent session to clear stale launcher state. Re-test run_terminal_command from the worktree after restart. Once working, re-attempt PR #545 finalization steps. Update #556 and #552 with fix confirmation.

Do not proceed to code changes or PR work until terminal proven functional.

## Diagnosis Update (current session) **Failure still reproduces exactly** as described in #556. Every invocation of `run_terminal_command` (and `monitor`) fails with: `Tool run_terminal_command failed: Terminal error: IO Error: No such file or directory (os error 2)` **Safe non-mutating tests attempted (all failed identically):** - `pwd` - `echo ok` - `/bin/echo ...` - `/usr/bin/python3 --version` - `git -C /full/path/to/worktree ...` - `ls /absolute/path` - `PWD=/tmp /usr/bin/env -i ... /bin/zsh -c 'cd /worktree && ...'` - Python subprocess wrappers with os.chdir + subprocess - Commands targeting root and the exact worktree `/Users/jasonwalker/Development/Gitea-Tools/branches/fix-issue-531-mcp-eof-defect` - `git --version` absolute **list_dir and other FS tools work** (e.g. list_dir on / and worktree succeeds, showing /bin/sh, /bin/zsh, /usr/bin/git, /usr/bin/python3 exist). **grep/read_file work** for code inspection. **No shell command succeeds.** **Likely cause classification:** - Broken terminal launcher wrapper in the agent runtime (not a missing executable or PATH issue, since FS tools see the bins). - Stale/invalid cwd in the underlying shell process (ENOENT on spawn/chdir/getcwd). Likely from prior `cd` into a deleted nested worktree path (e.g. during earlier author worktree ops for PRs). - Not project worktree specific (fails even for simple pwd/echo). - Not permissions (list_dir works). - Agent/session process state corruption. **Repo-owned?** No. The `run_terminal_command` tool is provided by the host agent platform (not implemented in Gitea-Tools source). No code change in this repo can fix the launcher. The project's code has shell spawn circuit-breaker handling (#258, #270 in gitea_mcp_server.py, native_mcp_preference.py), but the failure happens at the tool call layer before any project code runs. **Recovery steps attempted:** - Various command forms, absolute paths, clean env, PWD override, python wrappers, subagents with cwd= param, monitor tool. - All same error. - Non-mutating FS inspection only (no root mutations, no edits to fix-issue-531 worktree yet). **BLOCKED + DIAGNOSE per #552 rule.** **Recommended durable fix (operator / platform):** 1. Restart the current agent/LLM session or the host process to reset the shell wrapper's internal cwd to a valid dir (e.g. project root or /tmp). 2. Add preflight in agent launcher: before spawning, verify getcwd() succeeds or chdir(/) as fallback; emit clear diagnostic like "launcher_cwd_invalid: <bad_path>" or "shell_spawn_failed: ENOENT cwd=<...> exec=<...>". 3. Distinguish in errors: missing shell vs missing cwd vs missing exec vs wrapper bug. 4. Update agent docs or this project's runbooks if needed. **No mutations occurred** in this diagnosis pass (only reads, MCP calls for issue view, list, comments for context, grep for code mentions of shell spawn). **Single next action:** Operator/platform restart of agent session to clear stale launcher state. Re-test `run_terminal_command` from the worktree after restart. Once working, re-attempt PR #545 finalization steps. Update #556 and #552 with fix confirmation. Do not proceed to code changes or PR work until terminal proven functional.
jcwalker3 added status:pr-open and removed status:in-progress labels 2026-07-09 09:29:27 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#556