{"record":{"id":"5667e9fdc8270362","repo":"BoundaryML/baml","slug":"has-no-baml-toml-run-baml-init-before-adding-a-generator","errorCode":null,"errorMessage":"`{}` has no baml.toml; run `baml init` before adding a generator","messagePattern":"`(.+?)` has no baml\\.toml; run `baml init` before adding a generator","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_cli/src/generate.rs","lineNumber":108,"sourceCode":"    /// Resolved output directory (absolute).\n    output_dir: PathBuf,\n    /// Required `naming_convention` from the generator section. No default\n    /// is permitted — generators must spell out the policy explicitly.\n    naming_convention: NamingConvention,\n    /// Required for Go so generated packages can import the SDK root and one\n    /// another. Other generators leave this unset.\n    sdk_import_path: Option<String>,\n    max_typed_union_arity: usize,\n}\n\nimpl AddGeneratorArgs {\n    fn run(&self) -> Result<crate::ExitCode> {\n        let root = crate::project_load::find_project_root_from(self.from.as_deref())?.ok_or_else(\n            || anyhow!(\"no BAML project found; run `baml init` before adding a generator\"),\n        )?;\n        let toml_path = root.join(\"baml.toml\");\n        if !toml_path.is_file() {\n            anyhow::bail!(\n                \"`{}` has no baml.toml; run `baml init` before adding a generator\",\n                root.display()\n            );\n        }\n\n        let content = std::fs::read_to_string(&toml_path)\n            .with_context(|| format!(\"failed to read {}\", toml_path.display()))?;\n        let manifest = baml_db::manifest::parse(&content)\n            .with_context(|| format!(\"failed to parse {}\", toml_path.display()))?;\n        baml_db::manifest::package_name(&manifest, &toml_path)?;\n        // Every other manifest reader rejects these, so accepting them here\n        // would write a generator into a file that the next build refuses to\n        // load, reporting a failure that names neither this command nor the\n        // table it choked on.\n        baml_db::manifest::reject_stdlib_only_tables(&manifest, &toml_path)?;\n\n        let mut generator = Generator::from(self.output_type);\n        match (self.output_type, self.sdk_import_path.as_deref()) {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_cli/src/generate.rs#L90-L126","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n$ ls my-project/   # baml_src only, no baml.toml\n// after\n$ cd my-project && baml init   # recreates baml.toml","handlingStrategy":"validation","validationCode":"test -f baml.toml || { echo 'missing baml.toml at project root; run baml init' >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["cli","config-file","not-found"],"backgroundTag":"config-file-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}