pola-rs/polars · critical
failed to create spill directory
Error message
failed to create spill directory: {e} (path = {process_dir:?}) What it means
polars-ooc initializes its out-of-core spill directory lazily as <configured spill dir>/<pid>. If create_dir_owner_only fails (bad path, permissions, filesystem errors), it panics with the underlying error and the attempted path. Without a spill directory, no out-of-core execution can proceed.
Solutions
- Set POLARS_OOC_SPILL_DIR to an existing, writable directory (e.g. /tmp or a dedicated volume) and ensure it exists before running.
- Create the directory and fix permissions: mkdir -p $POLARS_OOC_SPILL_DIR && chmod u+rwx $POLARS_OOC_SPILL_DIR.
- Run the container/process as a user that owns the spill dir, or chown/chmod the path accordingly.
- Check disk space and mount status of the configured volume; disable OOC features if streaming fits in memory.
Example fix
// before POLARS_OOC_SPILL_DIR=/var/lib/polars-ooc # root-owned, process runs as appuser // after export POLARS_OOC_SPILL_DIR=/tmp/polars-ooc && mkdir -p /tmp/polars-ooc && chown appuser /tmp/polars-ooc
Defensive patterns
Strategy: validation
Validate before calling
use std::path::Path;
fn spill_dir_writable(dir: &str) -> Result<(), String> {
let p = Path::new(dir);
if !p.is_dir() { return Err(format!("{dir} is not a directory")); }
let probe = p.join(".polars-ooc-probe");
std::fs::write(&probe, b"x").map_err(|e| e.to_string())?;
std::fs::remove_file(&probe).map_err(|e| e.to_string())?;
Ok(())
}
// call at startup with the value of POLARS_OOC_SPILL_DIR before running OOC queries Prevention
- Verify POLARS_OOC_SPILL_DIR exists and is writable at process startup.
- In containers, mount a dedicated writable volume for spill data.
- Run the process as a user with ownership of the spill directory.
- Monitor disk space on the spill volume.
When it happens
Trigger: First use of a SpillFile (i.e. any OOC operation) when POLARS_OOC_SPILL_DIR (or config ooc_spill_dir) points to a non-existent/unwritable location, a read-only filesystem, or a path the current user lacks permission to create directories under.
Common situations: Containers running as non-root with POLARS_OOC_SPILL_DIR pointing at a root-owned path; spill dir on a tmpfs/volume not mounted; misconfigured env var with typos or invalid paths; disk-full conditions on /tmp.
Understand the failure class
Background: mkdir permission denied (EACCES): failed to create directory errors explained — this error's family across 32 libraries.
Related errors
- failed to create file cache data directory: path =
- failed to create file cache directory: path =
- failed to create file cache metadata directory: path =
- failed to open/create global file cache lockfile
- could not read
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/f57a3468c76a3403.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-ooc/src/spill_file.rs:20
use std::sync::LazyLock;
use std::sync::mpsc::{Receiver, Sender, channel};
use polars_io::create_dir_owner_only;
use crate::BYTES_SPILLED_TO_DISK;
/// On-disk layout:
///
/// ```text
/// <spill_dir>/
/// <pid>/ <- process directory (one per OS process)
/// spill-<ctx>-<uuid>.ipc <- individual spill file (unique per spill)
/// ```
static SPILL_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
let spill_dir = polars_config::config().ooc_spill_dir();
let process_dir = spill_dir.join(std::process::id().to_string());
create_dir_owner_only(&process_dir).unwrap_or_else(|e| {
panic!("failed to create spill directory: {e} (path = {process_dir:?})")
});
process_dir
});
pub struct SpillFile {
path: PathBuf,
size: u64,
}
impl SpillFile {
pub fn new(context_id: &str, ext: &str, size: u64) -> Self {
let uuid = uuid::Uuid::now_v7();
Self {
path: SPILL_DIR
.join(format!(
"spill-{context_id}-{uuid}.{ext}",
uuid = uuid.as_hyphenated()
))View on GitHub (pinned to fe841f959e)