{"record":{"id":"f57a3468c76a3403","repo":"pola-rs/polars","slug":"failed-to-create-spill-directory-e-path-pro","errorCode":null,"errorMessage":"failed to create spill directory: {e} (path = {process_dir:?})","messagePattern":"failed to create spill directory: (.+?) \\(path = (.+?)\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/polars-ooc/src/spill_file.rs","lineNumber":20,"sourceCode":"use std::sync::LazyLock;\nuse std::sync::mpsc::{Receiver, Sender, channel};\n\nuse polars_io::create_dir_owner_only;\n\nuse crate::BYTES_SPILLED_TO_DISK;\n\n/// On-disk layout:\n///\n/// ```text\n/// <spill_dir>/\n///   <pid>/                     <- process directory (one per OS process)\n///     spill-<ctx>-<uuid>.ipc   <- individual spill file (unique per spill)\n/// ```\nstatic SPILL_DIR: LazyLock<PathBuf> = LazyLock::new(|| {\n    let spill_dir = polars_config::config().ooc_spill_dir();\n    let process_dir = spill_dir.join(std::process::id().to_string());\n    create_dir_owner_only(&process_dir).unwrap_or_else(|e| {\n        panic!(\"failed to create spill directory: {e} (path = {process_dir:?})\")\n    });\n    process_dir\n});\n\npub struct SpillFile {\n    path: PathBuf,\n    size: u64,\n}\n\nimpl SpillFile {\n    pub fn new(context_id: &str, ext: &str, size: u64) -> Self {\n        let uuid = uuid::Uuid::now_v7();\n        Self {\n            path: SPILL_DIR\n                .join(format!(\n                    \"spill-{context_id}-{uuid}.{ext}\",\n                    uuid = uuid.as_hyphenated()\n                ))","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-ooc/src/spill_file.rs#L2-L38","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nPOLARS_OOC_SPILL_DIR=/var/lib/polars-ooc  # root-owned, process runs as appuser\n// after\nexport POLARS_OOC_SPILL_DIR=/tmp/polars-ooc && mkdir -p /tmp/polars-ooc && chown appuser /tmp/polars-ooc","handlingStrategy":"validation","validationCode":"use std::path::Path;\nfn spill_dir_writable(dir: &str) -> Result<(), String> {\n    let p = Path::new(dir);\n    if !p.is_dir() { return Err(format!(\"{dir} is not a directory\")); }\n    let probe = p.join(\".polars-ooc-probe\");\n    std::fs::write(&probe, b\"x\").map_err(|e| e.to_string())?;\n    std::fs::remove_file(&probe).map_err(|e| e.to_string())?;\n    Ok(())\n}\n// call at startup with the value of POLARS_OOC_SPILL_DIR before running OOC queries","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["filesystem","permissions","ooc","configuration","panic"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}