openai/codex · error

failed to remove protected create marker directory

Error message

failed to remove protected create marker directory {}: {err}

What it means

Removing the marker directory of a protected-create target failed during cleanup. This panic in cleanup_protected_create_targets fires when fs::remove_dir on the marker dir errors other than NotFound/DirectoryNotEmpty — the directory should be removable at this point, so failure points to permissions or IO trouble blocking teardown of the protected-create bookkeeping.

Solutions

  1. Read the io::Error errno in the message to classify the failure
  2. Verify permissions on the marker directory in the registry temp root
  3. Remove leftover marker dirs manually when no sandbox is active
  4. Report as a bug if removal succeeds manually
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1147 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/772ba19a02d227c5. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/linux-sandbox/src/linux_run_main.rs:1147

        for target in targets.iter().rev() {
            match fs::remove_file(&target.marker_file) {
                Ok(()) => {}
                Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
                Err(err) => panic!(
                    "failed to unregister protected create target {}: {err}",
                    target.target.path().display()
                ),
            }
        }

        let mut violation = false;
        for target in targets.iter().rev() {
            violation |= remove_protected_create_target(&target.target);
            match fs::remove_dir(&target.marker_dir) {
                Ok(()) => {}
                Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
                Err(err) if err.kind() == std::io::ErrorKind::DirectoryNotEmpty => {}
                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!(

View on GitHub (pinned to 339751715c)