{"record":{"id":"b2d0f28c0afe2687","repo":"sgl-project/sglang","slug":"multiple-cargo-packages-under-workspace-declare","errorCode":null,"errorMessage":"multiple Cargo packages under {workspace} declare python module {python_module!r}: {sorted(crate.package for crate in matches)}","messagePattern":"multiple Cargo packages under (.+?) declare python module (.+?): (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/rust_extensions/loader.py","lineNumber":199,"sourceCode":"        matches.append(\n            _CrateSpec(\n                package=package_name,\n                library=library,\n                python_module=python_module,\n                workspace=workspace,\n                features=tuple(sglang_metadata.get(\"features\", ())),\n            )\n        )\n\n    if not matches:\n        raise ModuleNotFoundError(\n            f\"no Cargo package under {workspace} declares \"\n            f'`[package.metadata.sglang] python-module = \"{python_module}\"`; '\n            f\"declared modules: {sorted(declared_modules)}\",\n            name=python_module,\n        )\n    if len(matches) > 1:\n        raise ValueError(\n            f\"multiple Cargo packages under {workspace} declare python module \"\n            f\"{python_module!r}: {sorted(crate.package for crate in matches)}\"\n        )\n    return matches[0]\n\n\ndef _build_context(crate: _CrateSpec) -> _BuildContext:\n    source_digest = _source_digest(crate.workspace)\n    toolchain = {\n        \"cargo\": _command_version(\n            \"cargo\", \"--version\", \"--verbose\", cwd=crate.workspace\n        ),\n        \"rustc\": _command_version(\"rustc\", \"-vV\", cwd=crate.workspace),\n    }\n    python_abi = {\n        \"cache_tag\": sys.implementation.cache_tag,\n        \"ext_suffix\": sysconfig.get_config_var(\"EXT_SUFFIX\"),\n        \"platform\": sysconfig.get_platform(),","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/rust_extensions/loader.py#L181-L217","documentation":"Multiple Cargo packages in the workspace declare the same python-module in their sglang metadata, making crate discovery ambiguous; the message lists the conflicting package names.","triggerScenarios":"Two crates both contain `[package.metadata.sglang] python-module = \"<same module>\"` (e.g. after copy-pasting a crate or a botched rename leaving the old manifest behind).","commonSituations":"Duplicating a crate directory without updating metadata; vendored fork coexisting with the original in one workspace.","solutions":["Remove or rename the python-module metadata in all but one crate","If both crates are legitimate, give them distinct python-module values and import the right one","Search the workspace: grep for the module string across Cargo.toml files"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import tomllib, pathlib, collections\ncounts = collections.Counter()\nfor p in pathlib.Path(ws).rglob(\"Cargo.toml\"):\n    d = tomllib.loads(p.read_text())\n    m = d.get(\"package\",{}).get(\"metadata\",{}).get(\"sglang\",{}).get(\"python-module\")\n    if m: counts[m] += 1\nassert counts[python_module] == 1","typeGuard":null,"tryCatchPattern":null,"preventionTips":["grep the workspace for the python-module string before adding a new crate","Delete stale manifests after renaming/splitting crates"],"tags":["rust","discovery","ambiguity","metadata"],"backgroundTag":"duplicate-module-registration","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}