{"record":{"id":"694e81a8595da59b","repo":"BoundaryML/baml","slug":"specified-run-directory-does-not-exist","errorCode":null,"errorMessage":"Specified run directory does not exist: {}","messagePattern":"Specified run directory does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-runtime/src/cli/optimize.rs","lineNumber":709,"sourceCode":"        println!(\"\\n{}\", \"=\".repeat(60));\n        println!(\"Applying changes...\");\n        crate::optimize::applier::write_changes_to_disk(&changes)?;\n\n        for change in &changes {\n            println!(\"  Updated: {}\", change.relative_path);\n        }\n        println!(\"\\nChanges applied successfully!\");\n        println!(\"Use 'git diff' to review changes, or 'git checkout .' to revert.\");\n\n        Ok(())\n    }\n\n    /// Run the TUI viewer mode\n    fn run_view_mode(&self) -> Result<OptimizeRunResult> {\n        let run_dir = if let Some(ref dir) = self.run_dir {\n            // Use explicitly specified run directory\n            if !dir.exists() {\n                anyhow::bail!(\"Specified run directory does not exist: {}\", dir.display());\n            }\n            dir.clone()\n        } else {\n            // Find the most recent run in .baml_optimize/\n            let from = BamlRuntime::parse_baml_src_path(&self.from)?;\n            let optimize_base_dir = from\n                .parent()\n                .map(|p| p.join(\".baml_optimize\"))\n                .unwrap_or_else(|| PathBuf::from(\".baml_optimize\"));\n\n            if !optimize_base_dir.exists() {\n                anyhow::bail!(\n                    \"No optimization runs found. Run 'baml-cli optimize' first.\\n\\\n                     Expected directory: {}\",\n                    optimize_base_dir.display()\n                );\n            }\n","sourceCodeStart":691,"sourceCodeEnd":727,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-runtime/src/cli/optimize.rs#L691-L727","documentation":"In run_view_mode (`baml-cli optimize --view`), if the user passes an explicit run directory via --run-dir, the command validates it exists before opening the TUI viewer. A non-existent path causes this bail. It means the previous optimization run directory you pointed at was deleted, moved, or misspelled.","triggerScenarios":"Running `baml-cli optimize --view --run-dir <dir>` where <dir>.exists() is false.","commonSituations":"Typo in the path, viewing from a different working directory with a relative path, .baml_optimize run folder cleaned up by CI or .gitignore/clean scripts.","solutions":["Check the path with `ls <dir>` and correct typos.","Use an absolute path if running from a different working directory.","Omit --run-dir so the viewer auto-selects the most recent run in .baml_optimize/.","Re-run `baml-cli optimize` to regenerate a run directory if it was deleted."],"exampleFix":"// before\nbaml-cli optimize --view --run-dir .baml_optimize/run_2026-09-10  // deleted\n// after\nbaml-cli optimize --view   # auto-picks latest run in .baml_optimize/","handlingStrategy":"validation","validationCode":"# guard before viewing\n[ -d \"$RUN_DIR\" ] || { echo \"run dir missing: $RUN_DIR\"; exit 1; }","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (String(e.message).includes('Specified run directory does not exist')) {\n    // drop --run-dir to auto-select the latest run\n  }\n}","preventionTips":["Use absolute paths for --run-dir.","Don't clean .baml_optimize between optimize and view.","Omit --run-dir and let the viewer pick the latest run."],"tags":["cli","optimize","filesystem","path"],"backgroundTag":"directory-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}