BoundaryML/baml · error
no BAML project found; run `baml init` before adding a gener
Error message
no BAML project found; run `baml init` before adding a generator
What it means
`baml generate add-generator` (the `--from` based generator-adding flow) first resolves the BAML project root via `find_project_root_from`. When no project root can be found in or above the given directory, it throws this error telling the user to initialize a project with `baml init` first.
Source
Thrown at baml_language/crates/baml_cli/src/generate.rs:104
/// `baml.toml`.
struct GeneratorDef {
name: String,
output_type: OutputType,
/// 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.View on GitHub (pinned to bd85ce9dee)
Solutions
- Run `baml init` in the directory to create a BAML project first.
- cd into your actual BAML project (the one containing baml.toml) before running the command.
- Pass the correct path via --from, e.g. --from path/to/my-baml-project.
- Verify the project marker file baml.toml still exists at the project root and restore it if deleted.
Example fix
// before (in a non-project directory) baml generate add-generator --from ./scratch // after baml init ./my-project cd my-project && baml generate add-generator
Defensive patterns
Strategy: validation
Validate before calling
#!/usr/bin/env bash if [ ! -f baml.toml ] && ! find . -maxdepth 3 -name baml.toml -print -quit | grep -q .; then echo "no BAML project here; run: baml init" >&2; exit 1 fi baml generate add-generator "$@"
Prevention
- Always run generator commands from inside a project containing baml.toml.
- Run `baml init` as the first step of any new-project script.
- Pass an explicit --from pointing at the project root in CI scripts.
When it happens
Trigger: Running the add-generator command with `--from` pointing at (or defaulting to) a directory that is not inside a BAML project — no baml.toml/baml_src markers found walking upward.
Common situations: Running the command outside a project (e.g. in $HOME or a fresh directory), pointing `--from` at the wrong subdirectory, or a project whose baml.toml was deleted/renamed so the root can no longer be detected.
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
- `{}` has no baml.toml; 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/eb7321a218424608.
Report an issue: GitHub.