{"record":{"id":"dfec3c3f1cd99cb2","repo":"sgl-project/sglang","slug":"lockfile-is-required-for-reproducible-cargo-bui","errorCode":null,"errorMessage":"{lockfile} is required for reproducible `cargo build --locked` builds","messagePattern":"(.+?) is required for reproducible `cargo build --locked` builds","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/rust_extensions/loader.py","lineNumber":152,"sourceCode":"def _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\", {})\n        declared_module = sglang_metadata.get(\"python-module\")\n        if declared_module is None:\n            continue\n        declared_modules.append(declared_module)","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/rust_extensions/loader.py#L134-L170","documentation":"The discovered Cargo workspace has Cargo.toml but no Cargo.lock; the loader enforces `cargo build --locked` for reproducibility and refuses to build without a lockfile.","triggerScenarios":"Calling load_rust_extension on a workspace whose Cargo.lock was deleted, gitignored, or never generated.","commonSituations":"A .gitignore that excludes Cargo.lock; fresh fork missing the lockfile; CI caching that strips the file.","solutions":["Restore or regenerate Cargo.lock (run `cargo generate-lockfile` in the workspace) and commit it","Remove the Cargo.lock entry from .gitignore","If installable, use the prebuilt wheel extension instead of source builds"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"lock = Path(workspace) / \"Cargo.lock\"\nif not lock.is_file():\n    subprocess.run([\"cargo\", \"generate-lockfile\"], cwd=workspace, check=True)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Commit Cargo.lock; never gitignore it in binary-crate workspaces","CI preflight asserts Cargo.lock exists"],"tags":["rust","cargo","lockfile","reproducibility"],"backgroundTag":"missing-lockfile","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}