{"record":{"id":"21b6792f2c017f42","repo":"rust-lang/cargo","slug":"does-not-exist-unable-to-build-with-the-stan-21b679","errorCode":null,"errorMessage":"{:?} does not exist, unable to build with the standard library, try:\n        rustup component add rust-src","messagePattern":"(.+?) does not exist, unable to build with the standard library, try:\n        rustup component add rust-src","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/compiler/standard_lib.rs","lineNumber":246,"sourceCode":"        .sysroot\n        .join(\"lib\")\n        .join(\"rustlib\")\n        .join(\"src\")\n        .join(\"rust\")\n        .join(\"library\");\n    let lock = src_path.join(\"Cargo.lock\");\n    if !lock.exists() {\n        let msg = format!(\n            \"{:?} does not exist, unable to build with the standard \\\n             library, try:\\n        rustup component add rust-src\",\n            lock\n        );\n        match target_data.gctx.get_env(\"RUSTUP_TOOLCHAIN\") {\n            Ok(rustup_toolchain) => {\n                anyhow::bail!(\"{} --toolchain {}\", msg, rustup_toolchain);\n            }\n            Err(_) => {\n                anyhow::bail!(msg);\n            }\n        }\n    }\n    Ok(src_path)\n}\n","sourceCodeStart":228,"sourceCodeEnd":252,"githubUrl":"https://github.com/rust-lang/cargo/blob/42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9/src/compiler/standard_lib.rs#L228-L252","documentation":"Identical to error 32 but `RUSTUP_TOOLCHAIN` is NOT set in the environment, so the suggestion omits the `--toolchain` argument. The `library/Cargo.lock` for rust-src is missing and you are not running under a rustup-managed toolchain override.","triggerScenarios":"Building with `-Zbuild-std` on a standalone/custom toolchain installation (e.g. a distro-packaged rustc, a Nix derivation, or a hand-built toolchain) where rust-src was not installed or its `Cargo.lock` is absent.","commonSituations":"Linux distro rustc packages; dev environments without rustup; CI images that install rustc via apt/dnf but not the source; Nix shells with `pkgs.rustc` but no `rustPlatform.rustLibSrc`.","solutions":["Install rust-src through your toolchain manager (rustup: `rustup component add rust-src`; Nix: add `rustPlatform.rustLibSrc`).","Ensure `RUSTUP_TOOLCHAIN` is exported if you are actually using rustup so error 32's better hint appears.","Point `RUSTC_LINK_SRC`/the build-std source path to a vendored rust source tree that includes `Cargo.lock`.","Switch to a rustup-managed toolchain for `-Zbuild-std` workflows."],"exampleFix":"// before (Nix shell)\nrustc = pkgs.rustc   # no source\ncargo +nightly build -Zbuild-std\n\n// after\nshell = pkgs.mkShell { buildInputs = [ pkgs.rustc pkgs.rustPlatform.rustLibSrc ]; }","handlingStrategy":"validation","validationCode":"fn library_lock_exists(src_root: &Path) -> bool {\n    src_root.join(\"library\").join(\"Cargo.lock\").exists()\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["On non-rustup installs, vendor rust source including `Cargo.lock`.","Set `RUSTUP_TOOLCHAIN` so the better hint (error 32) applies.","Document `-Zbuild-std` prerequisites in the project."],"tags":["cargo","build-std","rust-src","toolchain","environment"],"backgroundTag":null,"analyzedSha":"42eee92bc9aa4449f4e25d84e4ceb1cf8e0f87f9","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}