a-b-street/abstreet · error

problem removing file

Error message

problem removing file: {:?}

What it means

rm in the updater wraps fs_err::remove_file: a NotFound error is tolerated (the file is already gone), but any other io::ErrorKind (permission denied, directory, read-only filesystem, etc.) panics. The faulty input is the path whose deletion failed for a reason other than not existing — cleanup of downloaded/obsolete data cannot proceed.

Solutions

  1. Check permissions on the file and its parent directory
  2. Confirm the path is a file, not a directory (use a recursive/directory removal for dirs)
  3. Close processes locking the file (editors, CI caches, antivirus on Windows)
  4. Rerun the updater after fixing permissions

Example fix

// before
other_error => panic!("problem removing file: {:?}", other_error),
// after
other_error => {
    if fs_err::metadata(&path).map(|m| m.is_dir()).unwrap_or(false) {
        fs_err::remove_dir_all(&path)?;
    } else {
        panic!("problem removing file {}: {:?}", path, other_error);
    }
}
Defensive patterns

Strategy: validation

Validate before calling

let meta = std::fs::metadata(&path);
if meta.as_ref().map(|m| m.is_dir()).unwrap_or(false) {
    fs_err::remove_dir_all(&path)?;
} else if meta.is_ok() {
    fs_err::remove_file(&path)?;
}

Try / catch

match fs_err::remove_file(&path) {
    Ok(_) => {},
    Err(e) if e.kind() == std::io::ErrorKind::NotFound => {},
    Err(e) => return Err(e.into()), // handle instead of panicking
}

Prevention

When it happens

Trigger: Deleting a data file where the OS returns a non-NotFound error — e.g. removing a read-only file without permission, or a path that is a directory being removed with a file-only remove.

Common situations: Files locked/owned by another process or user; read-only checkouts in CI; path pointing at a directory; Windows file locks.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13). Data as JSON: /api/errors/ef856137d07a4196. Report an issue: GitHub.

Appendix: source

Thrown at updater/src/main.rs:402

fn rm(path: &str) {
    println!("> rm {}", path);
    match fs_err::remove_file(path) {
        Ok(_) => {}
        Err(e) => match e.kind() {
            std::io::ErrorKind::NotFound => {
                println!("file {} does not exist, continuing", &path);
            }
            other_error => {
                panic!("problem removing file: {:?}", other_error);
            }
        },
    }
}

View on GitHub (pinned to 0964f29315)