{"record":{"id":"e3df96cddeceb399","repo":"can1357/oh-my-pi","slug":"open-failed","errorCode":null,"errorMessage":"open failed: {}: {}","messagePattern":"open failed: (.+?): (.+?)","errorType":"exception","errorClass":"SortError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/sort.rs","lineNumber":2599,"sourceCode":"// The automatic buffer heuristics clamp to this range to avoid\n// over-committing memory on constrained systems while still keeping\n// reasonably large chunks for typical workloads.\nconst MIN_AUTOMATIC_BUF_SIZE: usize = 512 * 1024; // 512 KiB\nconst FALLBACK_AUTOMATIC_BUF_SIZE: usize = 32 * 1024 * 1024; // 32 MiB\nconst MAX_AUTOMATIC_BUF_SIZE: usize = 1024 * 1024 * 1024; // 1 GiB\n\n#[derive(Debug, Error)]\npub enum SortError {\n\t#[error(\"{0}\")]\n\tMessage(String),\n\n\t#[error(\"write failed: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tWriteFailed { path: OsString, error: std::io::Error },\n\n\t#[error(\"{}\", format_disorder(.file, .line_number, .line, .silent))]\n\tDisorder { file: OsString, line_number: usize, line: String, silent: bool },\n\n\t#[error(\"open failed: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tOpenFailed { path: PathBuf, error: std::io::Error },\n\n\t#[error(\"cannot read: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tReadFailed { path: PathBuf, error: std::io::Error },\n\n\t#[error(\"failed to open temporary file: {}\", strip_errno(.error))]\n\tOpenTmpFileFailed { error: std::io::Error },\n\n\t#[error(\"could not run compress program '{}': {}\", .prog, strip_errno(.error))]\n\tCompressProgExecutionFailed { prog: String, error: std::io::Error },\n\n\t#[error(\"{} terminated abnormally\", .prog.quote())]\n\tCompressProgTerminatedAbnormally { prog: String },\n\n\t#[error(\"cannot create temporary file in {}:\", .path.quote())]\n\tTmpFileCreationFailed { path: PathBuf },\n\n\t#[error(\"extra operand {}\\nfile operands cannot be combined with --files0-from\\nTry 'sort --help' for more information.\", .file.quote())]","sourceCodeStart":2581,"sourceCodeEnd":2617,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/sort.rs#L2581-L2617","documentation":"`SortError::OpenFailed` is raised when the sort builtin cannot open a named file operand, quoting the path and the stripped errno (e.g. No such file or directory, Permission denied). It wraps the std::io::Error from the open call.","triggerScenarios":"Passing a file operand whose path does not exist, is misspelled, is a directory, or lacks read permission to the sort builtin.","commonSituations":"Typos in paths; relative paths evaluated from the wrong working directory; file deleted between listing and sorting; reading from a path that requires elevated permissions.","solutions":["Verify the path exists and is a regular file (`ls -l <path>`).","Check permissions on the file and its parent directories.","Use an absolute path or correct the working directory.","If the file may legitimately be absent, fall back to reading stdin (`-` or piping)."],"exampleFix":"// before\nsort data.txt  # file in another directory\n\n// after\nsort ./logs/data.txt","handlingStrategy":"validation","validationCode":"for f in input_files {\n    match std::fs::metadata(f) {\n        Ok(m) if m.is_file() => {}\n        Ok(_) => eprintln!(\"{f} is not a regular file\"),\n        Err(e) => eprintln!(\"cannot access {f}: {e}\"),\n    }\n}","typeGuard":null,"tryCatchPattern":"match sort_result {\n    Err(SortError::OpenFailed { path, error }) => {\n        eprintln!(\"cannot open {}: {error}\", path.display());\n    }\n    Err(e) => eprintln!(\"sort: {e}\"),\n    Ok(_) => {}\n}","preventionTips":["Validate file operands exist and are readable before sorting.","Use absolute paths or fix the working directory in scripts.","Fall back to stdin ('-') when input may legitimately be absent."],"tags":["sort","io","filesystem","open"],"backgroundTag":"file-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}