{"record":{"id":"f8044790adf94803","repo":"pola-rs/polars","slug":"err-path","errorCode":null,"errorMessage":"{err}: {path}","messagePattern":"\\{err\\}: \\{path\\}","errorType":"exception","errorClass":"PolarsError","httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/io.rs","lineNumber":15,"sourceCode":"use std::fs::File;\nuse std::io;\nuse std::path::Path;\n\nuse polars_error::*;\n\npub fn _limit_path_len_io_err(path: &Path, err: io::Error) -> PolarsError {\n    let path = path.to_string_lossy();\n    let msg = if path.len() > 88 && !polars_config::config().verbose() {\n        let truncated_path: String = path.chars().skip(path.len() - 88).collect();\n        format!(\"{err}: ...{truncated_path} (set POLARS_VERBOSE=1 to see full path)\")\n    } else {\n        format!(\"{err}: {path}\")\n    };\n    io::Error::new(err.kind(), msg).into()\n}\n\npub fn open_file(path: &Path) -> PolarsResult<File> {\n    File::open(path).map_err(|err| _limit_path_len_io_err(path, err))\n}\n\npub fn open_file_write(path: &Path) -> PolarsResult<File> {\n    std::fs::OpenOptions::new()\n        .write(true)\n        .create(true)\n        .truncate(true)\n        .open(path)\n        .map_err(|err| _limit_path_len_io_err(path, err))\n}\n\npub fn create_file(path: &Path) -> PolarsResult<File> {\n    File::create(path).map_err(|err| _limit_path_len_io_err(path, err))\n}","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/crates/polars-utils/src/io.rs#L1-L33","documentation":"This is the _limit_path_len_io_err wrapper that polars attaches to filesystem errors: it appends the offending path to the underlying io::Error's message ('{err}: {path}'). When the path is longer than 88 characters and POLARS_VERBOSE is unset, the path is truncated to its last 88 characters and a hint to set POLARS_VERBOSE=1 is added. The actual cause is always the wrapped error kind (NotFound, PermissionDenied, IsADirectory, ...).","triggerScenarios":"Any local file open/stat failing through polars_utils::io::open_file / open_file_write or cloud path expansion metadata calls - missing file, wrong permissions, a directory where a file was expected - especially with deeply nested paths.","commonSituations":"Relative paths resolved against an unexpected cwd; permission mismatches in containers; typos; very long paths where the 88-char truncation hides which directory the file is actually in.","solutions":["Read the leading part of the message - it names the real io error; fix that root cause (correct path, create the file, adjust permissions)","Set POLARS_VERBOSE=1 so the full untruncated path is printed","Resolve relative paths against an explicit base directory before passing them in","For long paths, verify every parent directory exists and is traversable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let meta = std::fs::metadata(&path)\n    .map_err(|_| format!(\"path inaccessible: {}\", path.display()));\n// also check readable: File::open(&path).is_ok()","typeGuard":null,"tryCatchPattern":"match pl_result {\n    Err(PolarsError::IO(e)) => {\n        // message shape: \"<io error>: <path or ...last-88-chars>\"\n        eprintln!(\"io kind={:?} msg={}\", e.kind(), e);\n        // rerun with POLARS_VERBOSE=1 to see the full path\n    }\n    other => other?,\n}","preventionTips":["Run with POLARS_VERBOSE=1 when debugging long-path errors to see the untruncated path","Resolve relative paths against an explicit base directory before passing to polars","Pre-check existence and permissions of the file and all parent directories","Remember the real cause is the leading io error kind, not the path suffix"],"tags":["rust","polars","io","filesystem","error-message"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}