BoundaryML/baml · error · anyhow::Error

Multiple major.minor versions detected

Error message

Multiple major.minor versions detected: {versions_str}. Major and minor versions must match across all generators.

What it means

`common_version_up_to_patch` collects the baml versions declared by all generators in the project. If generators declare different major.minor versions, no single common version can be chosen, so this error is returned listing the conflicting versions. All generators in one project must agree on major.minor.

Solutions

  1. Align the `baml_version` in every generator block to the same major.minor version.
  2. Run your package manager's baml upgrade (e.g. `pip install -U baml-py` / `npm update @baml` style) across all generator runtimes.
  3. Delete or consolidate duplicate generator blocks pinned to old versions.
  4. Re-save/restart the language server after unifying versions.

Example fix

// before (conflicting)
generator lang_py { baml_version "0.80.1" }
generator lang_ts { baml_version "0.81.0" }
// after (aligned)
generator lang_py { baml_version "0.81.0" }
generator lang_ts { baml_version "0.81.0" }
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check generator versions across .baml files
let versions: Vec<String> = sources.iter().filter_map(|s| extract_baml_version(s)).collect();
let majors_minors: std::collections::HashSet<String> =
    versions.iter().map(|v| v.rsplit_once('.').unwrap().0.to_string()).collect();
if majors_minors.len() > 1 {
    panic!("align generator baml_version major.minor: {majors_minors:?}");
}

Prevention

When it happens

Trigger: Multiple `generator` blocks in .baml files (or generator configs feeding `get_common_generator_version` / `run`) specify different `baml_version` values that differ in major or minor, e.g. 0.80.x vs 0.81.x.

Common situations: Upgrading one generator's baml_version but not others after a `baml-cli` update; copying a .baml file from another project with an older pinned version; partially migrated monorepos.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/2af5f1f8923cf765. Report an issue: GitHub.

Appendix: source

Thrown at engine/language_server/src/baml_project/mod.rs:1527

                        *highest_patch = version.patch;
                    }
                })
                .or_insert(version.patch);
        } else {
            tracing::warn!("Invalid semver version in generator: {}", version_str);
            // Consider how to handle invalid versions - for now, we ignore them for the check
        }
    }

    // If there's more than one major.minor version, return an error
    if major_minor_versions.len() > 1 {
        let versions_str = major_minor_versions
            .keys()
            .map(|v| format!("'{v}'"))
            .collect::<Vec<_>>()
            .join(", ");

        let message = anyhow::anyhow!(
            "Multiple major.minor versions detected: {versions_str}. Major and minor versions must match across all generators."
        );
        Err(message)
    // If there's only one major.minor version, return it with the highest patch
    } else if let Some((version, _)) = major_minor_versions.into_iter().next() {
        if let Some(highest_patch) = highest_patch_by_major_minor.get(&version) {
            // Parse the version string to create a proper semver::Version
            if let Ok(mut v) = Version::parse(&format!("{version}.0")) {
                // Update with the highest patch version
                v.patch = *highest_patch;
                Ok(v.to_string())
            } else {
                Ok(format!("{version}.{highest_patch}"))
            }
        } else {
            Ok(version)
        }
    // Fallback to the runtime version if no valid versions were found

View on GitHub (pinned to bd85ce9dee)