{"record":{"id":"6cbd64ea31fd7dd3","repo":"sgl-project/sglang","slug":"rust-workspace-for-python-module-was-not-found-a","errorCode":null,"errorMessage":"Rust workspace for {python_module} was not found at {workspace}","messagePattern":"Rust workspace for (.+?) was not found at (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/rust_extensions/loader.py","lineNumber":148,"sourceCode":"        _stage_atomically(artifact, extension_path)\n        return _load_extension_from_path(crate.python_module, extension_path)\n\n\ndef _import_bundled_extension(module_name: str) -> ModuleType | None:\n    try:\n        return importlib.import_module(module_name)\n    except ModuleNotFoundError as exc:\n        if exc.name == module_name:\n            return None\n        raise\n\n\ndef _discover_crate(workspace: Path, python_module: str) -> _CrateSpec:\n    workspace = Path(workspace).resolve()\n    workspace_manifest = workspace / \"Cargo.toml\"\n    lockfile = workspace / \"Cargo.lock\"\n    if not workspace_manifest.is_file():\n        raise FileNotFoundError(\n            f\"Rust workspace for {python_module} was not found at {workspace}\"\n        )\n    if not lockfile.is_file():\n        raise FileNotFoundError(\n            f\"{lockfile} is required for reproducible `cargo build --locked` builds\"\n        )\n\n    matches: list[_CrateSpec] = []\n    declared_modules: list[str] = []\n    for manifest in _source_files(workspace):\n        if manifest.name != \"Cargo.toml\":\n            continue\n        with manifest.open(\"rb\") as file:\n            document = tomllib.load(file)\n        package = document.get(\"package\")\n        if not isinstance(package, dict):\n            continue\n        sglang_metadata = package.get(\"metadata\", {}).get(\"sglang\", {})","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/rust_extensions/loader.py#L130-L166","documentation":"The Rust extension loader could not find a Cargo.toml at the resolved workspace path, so it cannot discover the crate for the requested Python module. Thrown by _discover_crate during load_rust_extension.","triggerScenarios":"Calling load_rust_extension(python_module, workspace=...) where workspace lacks Cargo.toml — wrong path, missing checkout, or wheel install without bundled sources where the discovery path defaults incorrectly.","commonSituations":"Running from an installed wheel where Rust sources aren't shipped; passing an incorrect workspace path; shallow/partial clone missing rust crates.","solutions":["Verify the workspace path contains Cargo.toml and fix the path argument","Install a wheel that bundles the prebuilt extension so discovery is skipped","Re-clone/restore the missing Rust sources"],"exampleFix":"# before\nload_rust_extension(\"sglang._rust.overlap\", workspace=Path(\"/wrong/path\"))\n# after\nload_rust_extension(\"sglang._rust.overlap\", workspace=repo_root / \"rust\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\nws = Path(workspace).resolve()\nif not (ws / \"Cargo.toml\").is_file():\n    raise FileNotFoundError(f\"no Rust workspace at {ws}; use a wheel with bundled extension\")","typeGuard":null,"tryCatchPattern":"try:\n    load_rust_extension(module, workspace)\nexcept FileNotFoundError as e:\n    fallback_to_bundled_or_fail(e)","preventionTips":["Ship/install wheels with prebuilt extensions for source-less deployments","Verify workspace layout in a preflight check"],"tags":["rust","file-not-found","discovery","cargo"],"backgroundTag":"missing-build-manifest","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}