cross-rs/cross · error
no rust-std component available for
Error message
no rust-std component available for {}: must use nightly What it means
`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.
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.
Example fix
// before # rust-toolchain.toml channel = "stable" build-std = true # stable + build-std -> error // after # rust-toolchain.toml channel = "nightly" build-std = true
Defensive patterns
Strategy: validation
Validate before calling
fn build_std_ok(channel: &str, uses_build_std: bool) -> Result<(), String> {
if uses_build_std && channel != "nightly" {
Err(format!("-Z build-std requires a nightly toolchain (got {channel})"))
} else { Ok(()) }
} Try / catch
match setup_components(...) {
Err(e) if e.to_string().contains("must use nightly") =>
eprintln!("Switch toolchain to nightly (rustup install nightly) or drop build-std."),
other => other?,
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- invalid toolchain
- failed to get rustup version
- unknown prerelease tag
- unsupported rust target for file
- could not determine what toolchain to use for image…
AI-assisted analysis of cross-rs/cross@8c1a8aa4b6 (2026-09-13).
Data as JSON: /api/errors/7e7d99a87d066607.
Report an issue: GitHub.
Appendix: source
Thrown at src/rustup.rs:281
toolchain: &QualifiedToolchain,
msg_info: &mut MessageInfo,
) -> Result<bool> {
Ok(check_component(component, toolchain, msg_info)?.is_installed())
}
#[allow(clippy::too_many_arguments)]
pub fn setup_components(
target: &Target,
uses_build_std: bool,
toolchain: &QualifiedToolchain,
is_nightly: bool,
available_targets: AvailableTargets,
args: &crate::cli::Args,
msg_info: &mut MessageInfo,
) -> Result<(), color_eyre::Report> {
if !toolchain.is_custom {
if !is_nightly && uses_build_std {
eyre::bail!(
"no rust-std component available for {}: must use nightly",
target.triple()
);
}
if !uses_build_std
&& !available_targets.is_installed(target)
&& available_targets.contains(target)
{
install(target, toolchain, msg_info)?;
} else if !component_is_installed("rust-src", toolchain, msg_info)? {
install_component("rust-src", toolchain, msg_info)?;
}
if args
.subcommand
.clone()
.is_some_and(|sc| sc == crate::Subcommand::Clippy)
&& !component_is_installed("clippy", toolchain, msg_info)?View on GitHub (pinned to 8c1a8aa4b6)