pola-rs/polars · error

failed to create spill directory: {e} (path = {process_dir:?

Error message

failed to create spill directory: {e} (path = {process_dir:?})

What it means

Panic while initializing the out-of-core spill directory: create_dir_owner_only failed to create the per-process directory under the configured ooc spill dir (permissions, disk full, or a conflicting path). The message includes the io error and path; check/clean the spill directory or change the config.

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 9b5d73fd00)

Solutions

  1. Ensure the spill directory parent exists and is writable; check permissions and available disk space.
  2. Set the spill/temp directory to a valid writable path via the polars configuration.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: This panic/expect fires when execution reaches an unguarded state described by: "failed to create spill directory: {e} (path = {process_dir:?})". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.

Common situations: Encountered when input data or configuration does not meet the preconditions of the throwing code path ("failed to create spill directory: {e} (path = {process_dir:?})"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.


AI-assisted analysis of pola-rs/polars@9b5d73fd00 (2026-08-19). Data as JSON: /api/errors/f57a3468c76a3403. Report an issue: GitHub.