{"record":{"id":"899a9b1e25b03299","repo":"BoundaryML/baml","slug":"cannot-install-the-stdlib-source-root-for-err","errorCode":null,"errorMessage":"cannot install the stdlib source root for `{}`: {err}","messagePattern":"cannot install the stdlib source root for `(.+?)`: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"baml_language/crates/baml_db/src/db.rs","lineNumber":495,"sourceCode":"                // one starts.\n                Some(&root) => {\n                    assert_eq!(\n                        root.interface(self).is_some(),\n                        matches!(provenance(package.name), StdlibProvenance::Interface { .. }),\n                        \"the stdlib root for `{}` is already installed with the other provenance\",\n                        package.name\n                    );\n                    root\n                }\n                None => {\n                    let mut spec = SourceRootSpec::new(path, SourceRootKind::Stdlib)\n                        .named(Name::new(package.name))\n                        .depending_on(dependencies);\n                    if let StdlibProvenance::Interface { bytes } = provenance(package.name) {\n                        spec = spec.served_from(bytes);\n                    }\n                    self.add_source_root(spec).unwrap_or_else(|err| {\n                        panic!(\n                            \"cannot install the stdlib source root for `{}`: {err}\",\n                            package.name\n                        )\n                    })\n                }\n            };\n            if let StdlibProvenance::Source { files } = provenance(package.name) {\n                self.add_or_update_files_in(\n                    root,\n                    files\n                        .iter()\n                        .map(|(path, contents)| (path.as_path(), *contents)),\n                );\n            }\n            roots.insert(package.name, root);\n        }\n        let lang = baml_base::LangPackage::ALL\n            .into_iter()","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_db/src/db.rs#L477-L513","documentation":"Panic from `install_stdlib` (invoked by `ensure_stdlib_sources` and `ensure_precompiled_stdlib`). Adding one of the stdlib's builtin source roots failed with a `SourceRootError`, which the installer treats as an unrecoverable internal invariant: the embedded stdlib must always be installable.","triggerScenarios":"`add_source_root` returns any error while installing a stdlib root — e.g. a non-stdlib root already exists at the `<builtin>/<pkg>` path, a dependency edge is rejected, or the root is already installed with the other provenance (the adjacent `assert_eq!` guard).","commonSituations":"Calling `ensure_stdlib_sources` after another root was added (stdlib must be installed first); mixing `ensure_stdlib_sources` and `ensure_precompiled_stdlib` on the same database; embedding a conflicting path.","solutions":["Install the stdlib (via `ensure_stdlib_sources` or `ensure_precompiled_stdlib`) as the very first operation on a fresh `ProjectDatabase`, before any user roots.","Do not mix source-provenance and interface-provenance stdlib installation on the same database.","If this appears despite correct ordering, it signals a compiler bug — file an issue with the inner error message."],"exampleFix":"// before\nlet mut db = ProjectDatabase::new();\ndb.add_source_root(user_root)?; // non-stdlib root installed first\ndb.ensure_stdlib_sources(); // panics\n// after\nlet mut db = ProjectDatabase::new();\ndb.ensure_stdlib_sources();\ndb.add_source_root(user_root)?;","handlingStrategy":"validation","validationCode":"fn stdlib_installed_first(db: &ProjectDatabase) -> bool {\n    db.roots().iter().all(|r| r.kind() == SourceRootKind::Stdlib)\n}","typeGuard":null,"tryCatchPattern":"// install_stdlib panics instead of returning Result; guard the ordering invariant before calling.\nassert!(stdlib_installed_first(&db), \"install stdlib before adding user roots\");\ndb.ensure_stdlib_sources();","preventionTips":["Call ensure_stdlib_sources/ensure_precompiled_stdlib immediately after constructing the database.","Never mix source and interface stdlib provenance on one database.","Keep a single initialization helper that installs the stdlib first, then user roots."],"tags":["panic","stdlib","rust","initialization-order"],"backgroundTag":"module-init-failed","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"}