{"record":{"id":"7e7d99a87d066607","repo":"cross-rs/cross","slug":"no-rust-std-component-available-for-must-use-nightly","errorCode":null,"errorMessage":"no rust-std component available for {}: must use nightly","messagePattern":"no rust-std component available for (.+?): must use nightly","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/rustup.rs","lineNumber":281,"sourceCode":"    toolchain: &QualifiedToolchain,\n    msg_info: &mut MessageInfo,\n) -> Result<bool> {\n    Ok(check_component(component, toolchain, msg_info)?.is_installed())\n}\n\n#[allow(clippy::too_many_arguments)]\npub fn setup_components(\n    target: &Target,\n    uses_build_std: bool,\n    toolchain: &QualifiedToolchain,\n    is_nightly: bool,\n    available_targets: AvailableTargets,\n    args: &crate::cli::Args,\n    msg_info: &mut MessageInfo,\n) -> Result<(), color_eyre::Report> {\n    if !toolchain.is_custom {\n        if !is_nightly && uses_build_std {\n            eyre::bail!(\n                \"no rust-std component available for {}: must use nightly\",\n                target.triple()\n            );\n        }\n\n        if !uses_build_std\n            && !available_targets.is_installed(target)\n            && available_targets.contains(target)\n        {\n            install(target, toolchain, msg_info)?;\n        } else if !component_is_installed(\"rust-src\", toolchain, msg_info)? {\n            install_component(\"rust-src\", toolchain, msg_info)?;\n        }\n        if args\n            .subcommand\n            .clone()\n            .is_some_and(|sc| sc == crate::Subcommand::Clippy)\n            && !component_is_installed(\"clippy\", toolchain, msg_info)?","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/rustup.rs#L263-L299","documentation":"`setup_components` refuses to proceed when a non-nightly toolchain is combined with `-Z build-std`, because only nightly rustc ships the `rust-src`/`rust-std` sources needed to compile the standard library from source. The error names the target triple that lacks the component. It is an upfront configuration check, not a build failure.","triggerScenarios":"Calling `setup_components` with `is_custom == false`, a toolchain that is not nightly, and `uses_build_std == true` (e.g. `--build-std` requested for a target while using stable/beta toolchain).","commonSituations":"Cross-compiling for a target without prebuilt std using `-Zbuild-std` while pinned to stable; old config enabling build-std but toolchain channel later switched from nightly to stable; cargo config in .cargo/config.toml enabling build-std unconditionally.","solutions":["Switch to a nightly toolchain (e.g. `nightly-2023-05-01`) — build-std requires nightly.","Remove the build-std requirement if a prebuilt `rust-std` for the target exists (use `rustup target add <triple>` on nightly instead).","Set the channel explicitly in rust-toolchain.toml to `nightly` when the target has no distributed std component.","Use a custom-built toolchain (`is_custom == true`) that already includes rust-std/rust-src if nightly is not acceptable."],"exampleFix":"// before\n# rust-toolchain.toml\nchannel = \"stable\"\nbuild-std = true  # stable + build-std -> error\n// after\n# rust-toolchain.toml\nchannel = \"nightly\"\nbuild-std = true","handlingStrategy":"validation","validationCode":"fn build_std_ok(channel: &str, uses_build_std: bool) -> Result<(), String> {\n    if uses_build_std && channel != \"nightly\" {\n        Err(format!(\"-Z build-std requires a nightly toolchain (got {channel})\"))\n    } else { Ok(()) }\n}","typeGuard":null,"tryCatchPattern":"match setup_components(...) {\n    Err(e) if e.to_string().contains(\"must use nightly\") =>\n        eprintln!(\"Switch toolchain to nightly (rustup install nightly) or drop build-std.\"),\n    other => other?,\n}","preventionTips":["Enable build-std only with nightly toolchains; pin nightly in rust-toolchain.toml when build-std is on.","Prefer `rustup target add <triple>` when a prebuilt std exists for the target.","Audit .cargo/config.toml for stale build-std settings after channel changes."],"tags":["rustup","build-std","nightly","cross-compilation","toolchain"],"backgroundTag":"unsupported-operation","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}