{"record":{"id":"4b57c22a5501813e","repo":"BoundaryML/baml","slug":"run-directory-does-not-exist","errorCode":null,"errorMessage":"Run directory does not exist: {}","messagePattern":"Run directory does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/optimize/storage.rs","lineNumber":119,"sourceCode":"impl OptimizationStorage {\n    /// Create a new optimization storage for a run\n    pub fn new(run_dir: &Path) -> Result<Self> {\n        std::fs::create_dir_all(run_dir).context(\"Failed to create run directory\")?;\n\n        // Create subdirectories\n        std::fs::create_dir_all(run_dir.join(\"candidates\"))?;\n        std::fs::create_dir_all(run_dir.join(\"evaluations\"))?;\n        std::fs::create_dir_all(run_dir.join(\"reflections\"))?;\n\n        Ok(Self {\n            run_dir: run_dir.to_path_buf(),\n        })\n    }\n\n    /// Load an existing optimization storage\n    pub fn from_existing(run_dir: &Path) -> Result<Self> {\n        if !run_dir.exists() {\n            anyhow::bail!(\"Run directory does not exist: {}\", run_dir.display());\n        }\n\n        Ok(Self {\n            run_dir: run_dir.to_path_buf(),\n        })\n    }\n\n    /// Get the run directory path\n    pub fn run_dir(&self) -> &Path {\n        &self.run_dir\n    }\n\n    // =========================================================================\n    // Config\n    // =========================================================================\n\n    /// Save optimization configuration\n    pub fn save_config(&self, config: &OptimizationConfig) -> Result<()> {","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/optimize/storage.rs#L101-L137","documentation":"OptimizationStorage::from_existing loads storage for a previously started optimization run from its run directory. If the directory does not exist on disk, it bails with this error instead of creating one (use the creating constructor for new runs).","triggerScenarios":"Calling `from_existing(&run_dir)` with a path that was never created: wrong run id/directory name, resuming a run after deleting its directory, or a relative path resolved from the wrong working directory.","commonSituations":"Resuming an optimizer run by id after cleaning the output directory; typo in the run path; running the resume command from a different directory so the relative path no longer points at the run.","solutions":["Verify the run directory exists (`ls <run_dir>`) and use the exact path printed when the run was created.","If the run never existed, start a new optimization run instead of resuming (which creates the directory).","Run the resume command from the same working directory (or pass an absolute path) so the relative run_dir resolves correctly."],"exampleFix":"// before\nlet storage = OptimizationStorage::from_existing(Path::new(\"runs/opt-abc123\"))?; // deleted\n// after\nlet storage = OptimizationStorage::from_existing(Path::new(\"runs/opt-def456\"))?; // existing run dir","handlingStrategy":"validation","validationCode":"// Rust: check the run directory before resuming\nlet run_dir = Path::new(\"runs/opt-def456\");\nif !run_dir.exists() {\n    eprintln!(\"Run dir {} missing; start a new run or fix the path\", run_dir.display());\n}","typeGuard":null,"tryCatchPattern":"// Rust\nmatch OptimizationStorage::from_existing(&run_dir) {\n    Ok(storage) => { /* resume */ }\n    Err(e) if e.to_string().contains(\"does not exist\") => start_new_run(&run_dir)?,\n    Err(e) => return Err(e),\n}","preventionTips":["Record the run directory path printed at run creation time and reuse it verbatim.","Use absolute paths when resuming from scripts or cron jobs.","Do not delete run directories while optimizations referencing them may be resumed."],"tags":["filesystem","file-not-found","optimizer","resume"],"backgroundTag":"file-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}