sgl-project/sglang · error · ValueError
multiple Cargo packages under {workspace} declare python mod
Error message
multiple Cargo packages under {workspace} declare python module {python_module!r}: {sorted(crate.package for crate in matches)} What it means
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.
Source
Thrown at python/sglang/srt/rust_extensions/loader.py:199
matches.append(
_CrateSpec(
package=package_name,
library=library,
python_module=python_module,
workspace=workspace,
features=tuple(sglang_metadata.get("features", ())),
)
)
if not matches:
raise ModuleNotFoundError(
f"no Cargo package under {workspace} declares "
f'`[package.metadata.sglang] python-module = "{python_module}"`; '
f"declared modules: {sorted(declared_modules)}",
name=python_module,
)
if len(matches) > 1:
raise ValueError(
f"multiple Cargo packages under {workspace} declare python module "
f"{python_module!r}: {sorted(crate.package for crate in matches)}"
)
return matches[0]
def _build_context(crate: _CrateSpec) -> _BuildContext:
source_digest = _source_digest(crate.workspace)
toolchain = {
"cargo": _command_version(
"cargo", "--version", "--verbose", cwd=crate.workspace
),
"rustc": _command_version("rustc", "-vV", cwd=crate.workspace),
}
python_abi = {
"cache_tag": sys.implementation.cache_tag,
"ext_suffix": sysconfig.get_config_var("EXT_SUFFIX"),
"platform": sysconfig.get_platform(),View on GitHub (pinned to 0132848349)
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
Defensive patterns
Strategy: validation
Validate before calling
import tomllib, pathlib, collections
counts = collections.Counter()
for p in pathlib.Path(ws).rglob("Cargo.toml"):
d = tomllib.loads(p.read_text())
m = d.get("package",{}).get("metadata",{}).get("sglang",{}).get("python-module")
if m: counts[m] += 1
assert counts[python_module] == 1 Prevention
- grep the workspace for the python-module string before adding a new crate
- Delete stale manifests after renaming/splitting crates
When it happens
Trigger: 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).
Common situations: Duplicating a crate directory without updating metadata; vendored fork coexisting with the original in one workspace.
Related errors
- no Cargo package under {workspace} declares `[package.metada
- Rust workspace for {python_module} was not found at {workspa
- Multiple serve backends matched this request: {names}. Selec
- {name} must have dtype torch.int32
- {name} must be on the same device as block sparse tensors
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b2d0f28c0afe2687.
Report an issue: GitHub.