{"record":{"id":"b12038336fa1647b","repo":"sgl-project/sglang","slug":"failed-to-query-the-rust-toolchain-with-command","errorCode":null,"errorMessage":"failed to query the Rust toolchain with `{command} {' '.join(arguments)}`","messagePattern":"failed to query the Rust toolchain with `(.+?) (.+?)`","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/rust_extensions/loader.py","lineNumber":283,"sourceCode":"        directories[:] = sorted(\n            name for name in directories if name not in _IGNORED_SOURCE_DIRECTORIES\n        )\n        root_path = Path(root)\n        for filename in sorted(filenames):\n            yield root_path / filename\n\n\ndef _command_version(command: str, *arguments: str, cwd: Path) -> str:\n    try:\n        result = subprocess.run(\n            [command, *arguments],\n            check=True,\n            capture_output=True,\n            text=True,\n            cwd=cwd,\n        )\n    except (OSError, subprocess.CalledProcessError) as exc:\n        raise RuntimeError(\n            f\"failed to query the Rust toolchain with `{command} {' '.join(arguments)}`\"\n        ) from exc\n    return result.stdout.strip()\n\n\ndef _json_digest(value: object) -> str:\n    serialized = json.dumps(\n        value, sort_keys=True, separators=(\",\", \":\"), ensure_ascii=True\n    ).encode()\n    return hashlib.sha256(serialized).hexdigest()\n\n\ndef _cache_root(cache_dir: Path | None) -> Path:\n    if cache_dir is not None:\n        return Path(cache_dir).expanduser().resolve()\n    sglang_cache = envs.SGLANG_CACHE_DIR.get()\n    return Path(sglang_cache).expanduser().resolve() / \"rust_extensions\"\n","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/rust_extensions/loader.py#L265-L301","documentation":"The loader failed to run a Rust toolchain query command (e.g. `cargo --version` / `rustc --version`) — the process could not start or exited non-zero — so it cannot compute the build fingerprint.","triggerScenarios":"load_rust_extension with cargo/rustc missing from PATH, not executable, or crashing (corrupt toolchain, permission denied).","commonSituations":"CI image without Rust installed; activated conda env shadowing cargo; broken rustup installation; PATH not propagated to the Python process.","solutions":["Install Rust (rustup) and verify `cargo --version` runs in the same shell/env as Python","Fix PATH so the toolchain is visible to the Python process","Reinstall/repair a corrupted rustup toolchain","Prefer the prebuilt wheel extension to avoid needing a toolchain"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import shutil\nassert shutil.which(\"cargo\") and shutil.which(\"rustc\"), \"Rust toolchain required for source builds\"","typeGuard":null,"tryCatchPattern":"try:\n    load_rust_extension(...)\nexcept RuntimeError as e:\n    if \"Rust toolchain\" in str(e): install_rust_or_use_wheel()","preventionTips":["Install rustup in CI images that build from source","Prefer prebuilt wheels on machines without Rust"],"tags":["rust","toolchain","environment","subprocess"],"backgroundTag":"toolchain-not-found","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}