You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stale '(deleted)' self-exe path can break apply_patch after binary replacement #16097
apply_patch can fail when the running Codex binary is replaced during an active session, because execution may use a stale self-executable path ending in (deleted).
Why this happens
A tool runtime can receive a previously-captured codex_self_exe path. If the binary is replaced on disk (common in local Codex development), that path may no longer be valid for re-exec.
Repro (Linux)
Start Codex from an installed binary path (for example ~/.cargo/bin/codex).
Replace/reinstall that binary while the session is still running.
Trigger an apply_patch call.
Actual behavior
Sandbox invocation can include a deleted path for the inner command and then fail with ENOENT.
Example shape: --apply-seccomp-then-exec -- "/home/.../.cargo/bin/codex (deleted)" --codex-run-as-apply-patch ...
Expected behavior
If a captured self-executable path is stale/deleted, runtime should resolve a live executable path and continue.
Current downstream mitigation
Downstream currently mitigates this in apply_patch runtime by rejecting (deleted) self-exe paths and falling back to a live executable resolution path.
Request
Would upstream accept a centralized fix for self-executable resolution (shared utility / single source of truth), so all re-exec callsites are resilient to binary replacement, not only apply_patch?
This seems particularly relevant for developers frequently rebuilding/replacing the Codex binary during active sessions.
Activity
etraut-openai commentedon Mar 28, 2026
Don't delete or replace the codex binary while it's in use.
rebroad commentedon Apr 1, 2026
Fair enough! Well, if anyone else finds this useful, I patched it here: 2d5a17909af465cfbd9ee5bb9403030cb164776f