BoundaryML/baml · error
no .baml files found in
Error message
no .baml files found in {dir:#?} What it means
After walking the directory for files, baml_src_files() asserts that at least one file has the .baml extension. If the walk succeeded but found no .baml files, it bails with this error naming the directory. An empty or wrong-content source directory would otherwise produce a silently empty IR and confusing downstream failures.
Solutions
- Add at least one .baml file to the directory (e.g. baml_src/main.baml with a client and function definition)
- Verify you're pointing at the source folder (baml_src), not the generated output (baml_client)
- Check file extensions with `ls baml_src/*.baml` — restore any renamed/deleted files
- Re-run `baml-cli init` to scaffold a fresh project with example .baml files
Example fix
// before
$ ls baml_src # empty
// after
// baml_src/main.baml
client GPT4 {
provider openai
options {
model gpt-4o
api_key env.OPENAI_API_KEY
}
}
function ExtractResume(resume: string) -> string {
client GPT4
prompt #"Extract the name from {{ resume }}"#
} Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs';
const hasBaml = fs.readdirSync('baml_src').some((f) => f.endsWith('.baml'));
if (!hasBaml) throw new Error('baml_src contains no .baml files; add one or run baml-cli init'); Try / catch
try {
await generate();
} catch (e) {
if (/no .baml files found/i.test(e.message)) {
console.error('Add at least one .baml file to baml_src, or check you are not pointing at baml_client/');
}
throw e;
} Prevention
- Run baml-cli init when starting a project to scaffold .baml files
- Distinguish source dir (baml_src) from generated output (baml_client) in configs
- Never commit renames like main.baml.bak into the only source directory
- CI-check that baml_src/*.baml exists before running generation
When it happens
Trigger: Calling baml_src_files on a directory that exists, is a directory, but contains no files with the .baml extension (e.g. only .json, .ts, or nothing at all).
Common situations: Initializing a new project and running generation before writing any .baml files; renaming files to .txt/.baml.bak; pointing baml_src at an empty output directory (like baml_client) instead of the source folder; .baml files hidden by a bad include/exclude filter in a build tool.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- does not exist (expected a directory containing BAML files)
- is a file, not a directory (expected a directory containing…
- is not a directory (expected a directory containing BAML…
- I/O error
- {0:?}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/d2b9383dcc3f7a01.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-runtime/src/lib.rs:2283
})
.filter(|e| e.file_type().is_file())
.filter(|e| {
let Some(ext) = e.path().extension() else {
return false;
};
let Some(ext) = ext.to_str() else {
return false;
};
VALID_EXTENSIONS.contains(&ext)
})
.map(|e| e.path().to_path_buf())
.collect::<Vec<_>>();
if !src_files
.iter()
.any(|f| f.extension() == Some("baml".as_ref()))
{
anyhow::bail!("no .baml files found in {dir:#?}");
}
Ok(src_files)
}
View on GitHub (pinned to bd85ce9dee)