Ray's Knowledge Base
Unlock

Ansible refuses to run from an agent shell with non-blocking stdio unless stdin is /dev/null and output is piped

PitfallVerified 11 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

uv run ansible --version (or any ansible-playbook run) from the Claude Code Bash tool exits at once with: ERROR: Ansible requires blocking IO on stdin/stdout/stderr. Non-blocking file handles detected: <stderr>.

Cause#

ansible-core 2.21 checks that stdin, stdout and stderr are blocking; the agent harness hands the process non-blocking file handles.

Fix#

Give Ansible its own handles: uv run ansible-playbook ... </dev/null 2>&1 | cat. In a justfile, put </dev/null on the recipe line and pipe the just call through cat when an agent runs it. A normal terminal needs neither.

Evidence#

Ran 2026-10-11 with ansible-core 2.21.5 on macOS: the plain call failed with the error above; uv run ansible --version </dev/null 2>&1 | cat printed ansible [core 2.21.5], and mise exec -- just check-host 2>&1 | cat (recipe with </dev/null) ran the full playbook.

Also found by searching

  • Ansible requires blocking IO on stdin/stdout/stderr
  • Non-blocking file handles detected ansible
  • ansible fails in claude code bash tool
  • ansible-playbook exits immediately in agent shell