BoundaryML/baml · error
`{}` has no baml.toml; run `baml init` before adding a gener
Error message
`{}` has no baml.toml; run `baml init` before adding a generator What it means
After a project root is found, `AddGeneratorArgs::run` verifies that `baml.toml` actually exists as a file at the root. If the directory was detected as a project root but the manifest file is missing (or is a directory), it bails with this message including the resolved root path.
Source
Thrown at baml_language/crates/baml_cli/src/generate.rs:108
/// Resolved output directory (absolute).
output_dir: PathBuf,
/// Required `naming_convention` from the generator section. No default
/// is permitted — generators must spell out the policy explicitly.
naming_convention: NamingConvention,
/// Required for Go so generated packages can import the SDK root and one
/// another. Other generators leave this unset.
sdk_import_path: Option<String>,
max_typed_union_arity: usize,
}
impl AddGeneratorArgs {
fn run(&self) -> Result<crate::ExitCode> {
let root = crate::project_load::find_project_root_from(self.from.as_deref())?.ok_or_else(
|| anyhow!("no BAML project found; run `baml init` before adding a generator"),
)?;
let toml_path = root.join("baml.toml");
if !toml_path.is_file() {
anyhow::bail!(
"`{}` has no baml.toml; run `baml init` before adding a generator",
root.display()
);
}
let content = std::fs::read_to_string(&toml_path)
.with_context(|| format!("failed to read {}", toml_path.display()))?;
let manifest = baml_db::manifest::parse(&content)
.with_context(|| format!("failed to parse {}", toml_path.display()))?;
baml_db::manifest::package_name(&manifest, &toml_path)?;
// Every other manifest reader rejects these, so accepting them here
// would write a generator into a file that the next build refuses to
// load, reporting a failure that names neither this command nor the
// table it choked on.
baml_db::manifest::reject_stdlib_only_tables(&manifest, &toml_path)?;
let mut generator = Generator::from(self.output_type);
match (self.output_type, self.sdk_import_path.as_deref()) {View on GitHub (pinned to bd85ce9dee)
Solutions
- Create or restore baml.toml at the project root (re-run `baml init` or check it back out from git).
- Confirm baml.toml is a regular file, not a directory: ls -la <root>/baml.toml.
- If the project was partial, delete and re-init: `baml init` in the root.
- Add baml.toml to version control so it is never missing on fresh clones.
Example fix
// before $ ls my-project/ # baml_src only, no baml.toml // after $ cd my-project && baml init # recreates baml.toml
Defensive patterns
Strategy: validation
Validate before calling
test -f baml.toml || { echo 'missing baml.toml at project root; run baml init' >&2; exit 1; } Prevention
- Commit baml.toml to version control so fresh checkouts always have it.
- Do not name directories 'baml.toml' and never gitignore the manifest.
- After a failed/partial baml init, verify baml.toml exists before continuing.
When it happens
Trigger: The resolved project root directory exists but `root.join("baml.toml")` is not a file — e.g. the root was found via baml_src without a manifest, or baml.toml was deleted/replaced by a directory.
Common situations: Manually deleting or renaming baml.toml, a broken/partial `baml init`, a directory named baml.toml created by mistake, or checking out a repo where baml.toml is gitignored and absent.
Understand the failure class
Background: "Config file not found": what it means and how to fix it in docker-sync, Maven, Vagrant, Turborepo and other tools — this error's family across 60 libraries.
Related errors
- no BAML project found; run `baml init` before adding a gener
- function `{function_name}` not found
- function `{target_name}` not found
- usage: baml self-update unexpected arguments: {}
- usage: baml toolchain install <canary|nightly|version>
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/5667e9fdc8270362.
Report an issue: GitHub.