{"record":{"id":"ef856137d07a4196","repo":"a-b-street/abstreet","slug":"problem-removing-file","errorCode":null,"errorMessage":"problem removing file: {:?}","messagePattern":"problem removing file: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"updater/src/main.rs","lineNumber":402,"sourceCode":"fn rm(path: &str) {\n    println!(\"> rm {}\", path);\n    match fs_err::remove_file(path) {\n        Ok(_) => {}\n        Err(e) => match e.kind() {\n            std::io::ErrorKind::NotFound => {\n                println!(\"file {} does not exist, continuing\", &path);\n            }\n            other_error => {\n                panic!(\"problem removing file: {:?}\", other_error);\n            }\n        },\n    }\n}","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/updater/src/main.rs#L384-L420","documentation":"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.","triggerScenarios":"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.","commonSituations":"Files locked/owned by another process or user; read-only checkouts in CI; path pointing at a directory; Windows file locks.","solutions":["Check permissions on the file and its parent directory","Confirm the path is a file, not a directory (use a recursive/directory removal for dirs)","Close processes locking the file (editors, CI caches, antivirus on Windows)","Rerun the updater after fixing permissions"],"exampleFix":"// before\nother_error => panic!(\"problem removing file: {:?}\", other_error),\n// after\nother_error => {\n    if fs_err::metadata(&path).map(|m| m.is_dir()).unwrap_or(false) {\n        fs_err::remove_dir_all(&path)?;\n    } else {\n        panic!(\"problem removing file {}: {:?}\", path, other_error);\n    }\n}","handlingStrategy":"validation","validationCode":"let meta = std::fs::metadata(&path);\nif meta.as_ref().map(|m| m.is_dir()).unwrap_or(false) {\n    fs_err::remove_dir_all(&path)?;\n} else if meta.is_ok() {\n    fs_err::remove_file(&path)?;\n}","typeGuard":null,"tryCatchPattern":"match fs_err::remove_file(&path) {\n    Ok(_) => {},\n    Err(e) if e.kind() == std::io::ErrorKind::NotFound => {},\n    Err(e) => return Err(e.into()), // handle instead of panicking\n}","preventionTips":["Check permissions before deletions in shared/CI environments","Use idempotent deletion (ignore NotFound, return other errors) rather than panic","Ensure paths are files, not directories"],"tags":["rust","panic","file-io","permissions"],"backgroundTag":"file-write-failed","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}