openai/codex · error
failed to remove protected create target
Error message
failed to remove protected create target {}: {err} What it means
Removing the protected-create target itself (the guarded path bwrap was told to create protectively) failed after retries. This panic in remove_protected_create_target fires when try_remove_protected_create_target keeps erroring (other than transient DirectoryNotEmpty) across the retry budget, meaning cleanup cannot restore the pre-sandbox state for that path.
Solutions
- Inspect the underlying io::Error for the errno
- Check ownership and permissions of the protected-create path and its parent
- Remove the leftover path manually once the sandbox has exited
- Report as a bug if the path is otherwise removable
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1165 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/22d0bda77b1c715f.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1165
Err(err) => panic!(
"failed to remove protected create marker directory {}: {err}",
target.marker_dir.display()
),
}
}
violation
})
}
fn remove_protected_create_target(target: &crate::bwrap::ProtectedCreateTarget) -> bool {
for attempt in 0..100 {
match try_remove_protected_create_target(target) {
Ok(removal) => return removal.is_some(),
Err(err) if err.kind() == std::io::ErrorKind::DirectoryNotEmpty && attempt < 99 => {
thread::sleep(Duration::from_millis(1));
}
Err(err) => {
panic!(
"failed to remove protected create target {}: {err}",
target.path().display()
);
}
}
}
unreachable!("protected create removal retry loop should return or panic")
}
fn remove_protected_create_target_best_effort(
target: &crate::bwrap::ProtectedCreateTarget,
) -> Option<ProtectedCreateRemoval> {
for _ in 0..100 {
match try_remove_protected_create_target(target) {
Ok(removal) => return removal,
Err(err) if err.kind() == std::io::ErrorKind::DirectoryNotEmpty => {
thread::sleep(Duration::from_millis(1));
}View on GitHub (pinned to 339751715c)