Skip to content
Latchkey

Rust "no precompiled std" - Wrong Host Toolchain in CI

The installed toolchain's host triple does not match the runner it runs on -- for example a -gnu toolchain on an Alpine/musl runner. rustc cannot find a precompiled std for the host, so even a native build fails.

What this error means

On Alpine or another musl runner, a build fails to find std/core or the linker behaves oddly, because the toolchain was installed for x86_64-unknown-linux-gnu while the host is x86_64-unknown-linux-musl. rustup show reveals the mismatched host.

cargo
error[E0463]: can't find crate for `std`
  = note: the `x86_64-unknown-linux-gnu` toolchain is installed,
          but this runner's host is `x86_64-unknown-linux-musl`

Common causes

Toolchain host triple differs from the runner

rustup installed a toolchain for one host (commonly -gnu) while the container/runner is another (-musl). std is precompiled per host, so the wrong host has no usable std.

Glibc toolchain on a musl image

Alpine images use musl; a default glibc rustup install does not match and cannot link a native binary against the host's libc.

How to fix it

Install the toolchain for the correct host

Match the toolchain host triple to the runner.

Terminal
rustup toolchain install stable-x86_64-unknown-linux-musl
rustup default stable-x86_64-unknown-linux-musl
rustup show

Or add the musl target and build for it

Keep the gnu host but cross-target musl explicitly.

Terminal
rustup target add x86_64-unknown-linux-musl
cargo build --target x86_64-unknown-linux-musl

How to prevent it

  • Match the rustup host triple to the runner's libc (gnu vs musl).
  • Use the official rust:alpine image when you need musl.
  • Run rustup show to verify the active host before building.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →