{"record":{"id":"923c1f0f04dbea4a","repo":"can1357/oh-my-pi","slug":"1","errorCode":"1","errorMessage":"general io error: {0}","messagePattern":"general io error: (.+?)","errorType":"error_code","errorClass":"LsError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/ls.rs","lineNumber":3680,"sourceCode":"\nfn write_os_str<W: Write>(writer: &mut W, string: &OsStr) -> std::io::Result<()> {\n\twriter.write_all(&os_bytes_lossy(string))\n}\n}\n\nuse colors::StyleManager;\npub use config::{Config, options};\nuse config::{Dereference, Files, Sort, options::QUOTING_STYLE};\nuse dired::DiredOutput;\npub use display::Format;\nuse display::{display_items, display_size, should_display, show_dir_name};\n\n#[derive(Error, Debug)]\nenum LsError {\n\t#[error(\"invalid line width: '{0}'\")]\n\tInvalidLineWidth(String),\n\n\t#[error(\"general io error: {0}\")]\n\tIOError(#[from] std::io::Error),\n\n\t#[error(\"{}\", match .1.kind() {\n\t\tErrorKind::NotADirectory => format!(\"cannot access {}: Not a directory\", .0.quote()),\n\t\tErrorKind::NotFound => format!(\"cannot access {}: No such file or directory\", .0.quote()),\n\t\tErrorKind::PermissionDenied => match .1.raw_os_error().unwrap_or(1) {\n\t\t\t1 => format!(\"cannot access {}: Operation not permitted\", .0.quote()),\n\t\t\t_ => if *.3 {\n\t\t\t\tformat!(\"cannot open directory {}: Permission denied\", .0.quote())\n\t\t\t} else {\n\t\t\t\tformat!(\"cannot open file {}: Permission denied\", .0.quote())\n\t\t\t},\n\t\t},\n\t\t_ => if 9 == .1.raw_os_error().unwrap_or(1) {\n\t\t\tformat!(\"cannot open directory {}: Bad file descriptor\", .0.quote())\n\t\t} else {\n\t\t\tformat!(\"unknown io error: {}, '{:?}'\", .0.quote(), .1)\n\t\t},","sourceCodeStart":3662,"sourceCodeEnd":3698,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/ls.rs#L3662-L3698","documentation":"The ls builtin's IOError variant wraps a std::io::Error via #[from] as a generic fallback for filesystem failures not covered by the specialized cannot-access variant. It is displayed as 'general io error: {os error}' and exits with code 1.","triggerScenarios":"Directory reads or metadata calls failing with io errors other than NotADirectory/NotFound/PermissionDenied (e.g. ELOOP, EIO, EMFILE) while ls walks the path arguments.","commonSituations":"Broken symlink loops, failing disks, file-descriptor exhaustion when listing huge directory trees, odd filesystem errors on network mounts.","solutions":["Read the wrapped io::Error's errno for the root cause","Check for symlink loops or I/O problems on the target path","Retry if the error is transient (EIO/EMFILE) or raise the fd limit","Run ls on a subset of paths to isolate the failing one"],"exampleFix":"// before\nls(&host, &[\"/mnt/flaky\"])?;\n// after\nmatch ls(&host, &[\"/mnt/flaky\"]) {\n    Err(e) if e.kind() == std::io::ErrorKind::Interrupted => retry_ls(),\n    other => other?,\n}","handlingStrategy":"try-catch","validationCode":"fn check_path_accessible(p: &Path) -> std::io::Result<()> {\n    std::fs::metadata(p).map(|_| ( ))\n}","typeGuard":null,"tryCatchPattern":"match ls(&host, args) {\n    Err(e) => match e.downcast_ref::<std::io::Error>() {\n        Some(io) => eprintln!(\"ls io failure (kind={:?}): {io}\", io.kind()),\n        None => return Err(e),\n    },\n    ok => ok?,\n}","preventionTips":["Probe paths with metadata before listing","Watch for symlink loops (ELOOP) and transient errors (EIO) on network mounts","Raise the fd limit when recursing very large trees"],"tags":["filesystem","ls","io","os-error","exit-code-1"],"backgroundTag":"io-error","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}