BoundaryML/baml · error

Run directory does not exist

Error message

Run directory does not exist: {}

What it means

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).

Solutions

  1. Verify the run directory exists (`ls <run_dir>`) and use the exact path printed when the run was created.
  2. If the run never existed, start a new optimization run instead of resuming (which creates the directory).
  3. Run the resume command from the same working directory (or pass an absolute path) so the relative run_dir resolves correctly.

Example fix

// before
let storage = OptimizationStorage::from_existing(Path::new("runs/opt-abc123"))?; // deleted
// after
let storage = OptimizationStorage::from_existing(Path::new("runs/opt-def456"))?; // existing run dir
Defensive patterns

Strategy: validation

Validate before calling

// Rust: check the run directory before resuming
let run_dir = Path::new("runs/opt-def456");
if !run_dir.exists() {
    eprintln!("Run dir {} missing; start a new run or fix the path", run_dir.display());
}

Try / catch

// Rust
match OptimizationStorage::from_existing(&run_dir) {
    Ok(storage) => { /* resume */ }
    Err(e) if e.to_string().contains("does not exist") => start_new_run(&run_dir)?,
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/4b57c22a5501813e. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/optimize/storage.rs:119

impl OptimizationStorage {
    /// Create a new optimization storage for a run
    pub fn new(run_dir: &Path) -> Result<Self> {
        std::fs::create_dir_all(run_dir).context("Failed to create run directory")?;

        // Create subdirectories
        std::fs::create_dir_all(run_dir.join("candidates"))?;
        std::fs::create_dir_all(run_dir.join("evaluations"))?;
        std::fs::create_dir_all(run_dir.join("reflections"))?;

        Ok(Self {
            run_dir: run_dir.to_path_buf(),
        })
    }

    /// Load an existing optimization storage
    pub fn from_existing(run_dir: &Path) -> Result<Self> {
        if !run_dir.exists() {
            anyhow::bail!("Run directory does not exist: {}", run_dir.display());
        }

        Ok(Self {
            run_dir: run_dir.to_path_buf(),
        })
    }

    /// Get the run directory path
    pub fn run_dir(&self) -> &Path {
        &self.run_dir
    }

    // =========================================================================
    // Config
    // =========================================================================

    /// Save optimization configuration
    pub fn save_config(&self, config: &OptimizationConfig) -> Result<()> {

View on GitHub (pinned to bd85ce9dee)