pola-rs/polars · error · PolarsError
{err}: {path}
Error message
{err}: {path} What it means
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, ...).
Source
Thrown at crates/polars-utils/src/io.rs:15
use std::fs::File;
use std::io;
use std::path::Path;
use polars_error::*;
pub fn _limit_path_len_io_err(path: &Path, err: io::Error) -> PolarsError {
let path = path.to_string_lossy();
let msg = if path.len() > 88 && !polars_config::config().verbose() {
let truncated_path: String = path.chars().skip(path.len() - 88).collect();
format!("{err}: ...{truncated_path} (set POLARS_VERBOSE=1 to see full path)")
} else {
format!("{err}: {path}")
};
io::Error::new(err.kind(), msg).into()
}
pub fn open_file(path: &Path) -> PolarsResult<File> {
File::open(path).map_err(|err| _limit_path_len_io_err(path, err))
}
pub fn open_file_write(path: &Path) -> PolarsResult<File> {
std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.open(path)
.map_err(|err| _limit_path_len_io_err(path, err))
}
pub fn create_file(path: &Path) -> PolarsResult<File> {
File::create(path).map_err(|err| _limit_path_len_io_err(path, err))
}View on GitHub (pinned to df599052da)
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
Defensive patterns
Strategy: try-catch
Validate before calling
let meta = std::fs::metadata(&path)
.map_err(|_| format!("path inaccessible: {}", path.display()));
// also check readable: File::open(&path).is_ok() Try / catch
match pl_result {
Err(PolarsError::IO(e)) => {
// message shape: "<io error>: <path or ...last-88-chars>"
eprintln!("io kind={:?} msg={}", e.kind(), e);
// rerun with POLARS_VERBOSE=1 to see the full path
}
other => other?,
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- expected a file path; {path!r} is a directory
- the `columns` argument should contain a list of all integers
- `columns` arg should only have unique values, got {columns!r
- `fsspec` is required for `storage_options` argument
- empty data from {context}{hint}
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/f8044790adf94803.
Report an issue: GitHub.