{"record":{"id":"c9019a5740db8211","repo":"BoundaryML/baml","slug":"dependency-name-names-a-source-root-that-does-not-exist","errorCode":null,"errorMessage":"dependency `{name}` names a source root that does not exist","messagePattern":"dependency `(.+?)` names a source root that does not exist","errorType":"exception","errorClass":"SourceRootError","httpStatus":null,"severity":"error","filePath":"baml_language/crates/baml_db/src/db.rs","lineNumber":97,"sourceCode":"}\n\n/// Why [`ProjectDatabase::add_source_root`] or\n/// [`ProjectDatabase::add_dependency`] refused.\n#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]\npub enum SourceRootError {\n    /// A live root already sits at this (canonical) path.\n    #[error(\"a source root already exists at this path\")]\n    PathTaken(SourceRoot),\n    /// The edge name is one no package may declare: a stdlib package's name\n    /// (already an implicit edge of every package) or a source-level\n    /// qualifier (`root`, `env`).\n    #[error(\"dependency name `{name}` is reserved\")]\n    ReservedDependencyName { name: Name },\n    /// The root already has an edge under this name.\n    #[error(\"dependency `{name}` is declared twice\")]\n    DuplicateDependencyName { name: Name },\n    /// The edge names a root that is not live in this database.\n    #[error(\"dependency `{name}` names a source root that does not exist\")]\n    UnknownDependencyRoot { name: Name },\n    /// The edge would make the dependency graph cyclic.\n    #[error(\"dependency `{name}` would form a dependency cycle\")]\n    DependencyCycle { name: Name },\n    /// The interface bytes are not a valid `PackageInterface` artifact.\n    #[error(\"invalid package interface: {message}\")]\n    InvalidInterface { message: String },\n}\n\n/// The main database for BAML projects.\n///\n/// `ProjectDatabase` owns the Salsa storage directly and implements all the\n/// compiler `Db` traits. It provides high-level APIs for:\n/// - Source-root management (add/remove roots, longest-prefix lookup)\n/// - File management within a root (add/update/remove files)\n/// - Diagnostics collection via `check()`\n///\n/// ## Example","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/baml_language/crates/baml_db/src/db.rs#L79-L115","documentation":"Part of `SourceRootError` returned by `ProjectDatabase::add_source_root` / `add_dependency`. A dependency edge references a root `name` that is not a live source root in the database. Dependency edges must point at roots that have already been added.","triggerScenarios":"Calling `add_source_root` with `depending_on` where a `Dependency.root` name (or the referenced root) does not correspond to any root currently registered via `add_source_root`.","commonSituations":"Adding a project root that depends on another package before that package's root is installed; typos in dependency names; removing a root while other roots still depend on it.","solutions":["Add the dependency target's source root first (dependency order), then add the dependent root.","Verify the dependency name matches an existing root exactly (spelling/case).","If the target was removed, drop or update the stale dependency edge."],"exampleFix":"// before\ndb.add_source_root(app_spec.depending_on(vec![Dependency { name: \"core\".into(), .. }]))?; // core not added yet\n// after\ndb.add_source_root(core_spec)?;\ndb.add_source_root(app_spec.depending_on(vec![Dependency { name: \"core\".into(), .. }]))?;","handlingStrategy":"validation","validationCode":"fn deps_exist(deps: &[Dependency], db: &ProjectDatabase) -> Result<(), String> {\n    for d in deps {\n        if db.find_source_root(&d.name).is_none() {\n            return Err(format!(\"dependency `{}` is not a live root\", d.name));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match db.add_source_root(spec) {\n    Err(SourceRootError::UnknownDependencyRoot { name }) => eprintln!(\"add root `{name}` first\"),\n    Err(e) => eprintln!(\"root error: {e}\"),\n    Ok(root) => root,\n}","preventionTips":["Always install dependency targets before dependents (topological order).","Verify dependency names against the live root list before wiring edges.","Avoid deleting roots while others reference them."],"tags":["dependency-management","rust","missing-root"],"backgroundTag":"resource-not-found","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}