BoundaryML/baml · error

Expected --from '{}' to be a baml_src/ directory, but it doe

Error message

Expected --from '{}' to be a baml_src/ directory, but it does not exist

What it means

parse_baml_src_path validates the --from path before locating the BAML source directory. It fails immediately when the given path does not exist on disk, so the CLI/runtime cannot locate a baml_src directory from it.

Source

Thrown at engine/baml-runtime/src/lib.rs:544

            db,
            diagnostics,
            clients: Default::default(),
            retry_policies: Default::default(),
            source_files,
            tracer_wrapper: Arc::new(BamlTracerWrapper::new(env_vars)?),
            #[cfg(not(target_arch = "wasm32"))]
            async_runtime: rt.clone(),
            publisher_env_vars: Some(publisher_env_vars),
        };

        Ok(runtime)
    }

    pub fn parse_baml_src_path(path: impl Into<PathBuf>) -> Result<PathBuf> {
        let mut path: PathBuf = path.into();

        if !path.exists() {
            anyhow::bail!(
                "Expected --from '{}' to be a baml_src/ directory, but it does not exist",
                path.display()
            );
        }

        if !path.is_dir() {
            anyhow::bail!(
                "Expected --from '{}' to be a baml_src/ directory, but it is not",
                path.display()
            );
        }

        if path.file_name() != Some(std::ffi::OsStr::new("baml_src")) {
            let contained = path.join("baml_src");

            if contained.exists() && contained.is_dir() {
                path = contained;
            } else {

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Verify the path exists with ls/ls -la and correct any typo
  2. Run the command from the project root or pass an absolute path via --from
  3. Ensure baml_src/ is committed/present in container or CI images
  4. Confirm the correct folder name is baml_src (not baml-src or src)

Example fix

// before
BamlRuntime::from_directory("./baml_srcs")?;
// after
BamlRuntime::from_directory("./baml_src")?; // path must exist and be baml_src
Defensive patterns

Strategy: validation

Validate before calling

use std::path::Path;
fn validate_from(p: &str) -> Result<(), String> {
    let path = Path::new(p);
    if !path.exists() {
        return Err(format!("--from '{}' does not exist", p));
    }
    Ok(())
}

Prevention

When it happens

Trigger: Calling BamlRuntime::from_directory/parse_baml_src_path (or the CLI's --from flag) with a path that doesn't exist: typo'd path, wrong working directory, deleted or never-created baml_src folder.

Common situations: Running baml CLI from a different directory than the project root, renaming the baml_src folder, Docker images missing the source directory, CI checking out a partial repo.

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/46477c98957f9391. Report an issue: GitHub.