{"record":{"id":"4001dba863f779c1","repo":"rust-lang/rust","slug":"io-error-creating-mir-dump-file-file-path-e","errorCode":null,"errorMessage":"IO error creating MIR dump file: {file_path:?}; {e}","messagePattern":"IO error creating MIR dump file: (.+?); (.+?)","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"compiler/rustc_middle/src/mir/pretty.rs","lineNumber":305,"sourceCode":"    /// bit of MIR-related data. Used by `mir-dump`, but also by other\n    /// bits of code (e.g., NLL inference) that dump graphviz data or\n    /// other things, and hence takes the extension as an argument.\n    pub fn create_dump_file(\n        &self,\n        extension: &str,\n        body: &Body<'tcx>,\n    ) -> io::Result<io::BufWriter<fs::File>> {\n        let file_path = self.dump_path(extension, body);\n        if let Some(parent) = file_path.parent() {\n            fs::create_dir_all(parent).map_err(|e| {\n                io::Error::new(\n                    e.kind(),\n                    format!(\"IO error creating MIR dump directory: {parent:?}; {e}\"),\n                )\n            })?;\n        }\n        fs::File::create_buffered(&file_path).map_err(|e| {\n            io::Error::new(e.kind(), format!(\"IO error creating MIR dump file: {file_path:?}; {e}\"))\n        })\n    }\n}\n\n///////////////////////////////////////////////////////////////////////////\n// Whole MIR bodies\n\n/// Write out a human-readable textual representation of this crate's MIR,\n/// with the default [`PrettyPrintMirOptions`].\npub fn write_mir_pretty<'tcx>(tcx: TyCtxt<'tcx>, w: &mut dyn io::Write) -> io::Result<()> {\n    let writer = MirWriter::new(tcx);\n\n    writeln!(w, \"// WARNING: This output format is intended for human consumers only\")?;\n    writeln!(w, \"// and is subject to change without notice. Knock yourself out.\")?;\n    writeln!(w, \"// HINT: See also -Z dump-mir for MIR at specific points during compilation.\")?;\n\n    let mut first = true;\n    for &def_id in tcx.mir_keys(()) {","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/compiler/rustc_middle/src/mir/pretty.rs#L287-L323","documentation":"Returned by create_dump_file in rustc_middle::mir::pretty when fs::File::create_buffered fails while creating the actual MIR dump file. The file path includes crate name, item name, pass number, pass name, disambiguator, and extension. This is the second IO step after the parent directory is successfully created.","triggerScenarios":"Compiling with -Z dump-mir enabled; the output directory was created successfully, but opening the specific dump file fails. The full file_path is included in the error for diagnosis.","commonSituations":"Disk full; too many open files (ulimit -n); file path too long (especially on Windows with deep nesting); filename contains invalid characters for the OS; antivirus blocking file creation; file already exists as a directory; running in a CI environment with ephemeral/limited storage.","solutions":["Check the specific {file_path} in the error message for path-length or character issues.","Increase the open file descriptor limit: ulimit -n 4096 or higher.","Free disk space if the volume is full.","On Windows, enable long path support or use a shorter dump_mir_dir.","If the file_path suggests a naming collision (directory with the same name), remove the conflicting entry."],"exampleFix":"# before: too many open files during heavy MIR dumping\nulimit -n 256  cargo build  # fails creating dump file\n# after: raise the descriptor limit\nulimit -n 65536 cargo build","handlingStrategy":"validation","validationCode":"// Before a heavy MIR-dump session, check available file descriptors and disk space.\nfn check_resources_for_dump() -> Result<(), String> {\n    // Check disk space (Unix)\n    #[cfg(unix)]\n    {\n        let _ = std::fs::canonicalize(\".\").map_err(|e| format!(\"cwd error: {e}\"))?;\n    }\n    // Check ulimit is high enough (very rough heuristic)\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"// create_dump_file returns io::Result — handle gracefully in internal code:\nmatch self.create_dump_file(extension, body) {\n    Ok(writer) => writer,\n    Err(e) => {\n        tcx.sess.dcx().warn(format!(\"MIR dump skipped — IO error: {e}\"));\n        return Ok(()); // skip dump, continue compilation\n    }\n}","preventionTips":["Raise ulimit -n before running heavy MIR dump sessions.","Ensure sufficient disk space — MIR dumps can be large for big crates.","Use a dedicated dump directory with plenty of space (e.g., /tmp or a fast SSD).","On Windows, check for path-length issues (enable LongPathsEnabled)."],"tags":["rustc","mir","dump","io","debugging","unstable-flags"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}