Skip to content
Latchkey

Rust "error[E0463]: can't find crate for `std`" in CI

You are cross-compiling to a target whose standard library isn’t installed. rustc can’t find std for that target because the precompiled rust-std component was never added via rustup.

What this error means

A --target build fails with error[E0463]: can't find crate for std` (sometimes with a note that std` isn’t available for the target). The host build works; only the cross-target build fails for lack of its std.

cargo output
error[E0463]: can't find crate for `std`
  |
  = note: the `aarch64-unknown-linux-musl` target may not be installed
  = help: consider downloading the target with `rustup target add aarch64-unknown-linux-musl`

Diagnose it: toolchain, features, cache

Terminal
rustc --version --verbose && cargo --version
cat rust-toolchain.toml 2>/dev/null
cargo tree -e features | head -30
cargo clean && cargo build --locked

Common causes

Target std component not installed

Each cross-compilation target needs its own precompiled std (rust-std). Without rustup target add <target>, rustc has no std for it.

A no_std-only or tier-3 target

Some targets ship no prebuilt std at all. For those you need -Z build-std on nightly, or a #![no_std] crate, rather than a missing component.

How to fix it

Add the target’s std

rustup’s help line names the exact command - install the target component.

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

Request the target in the setup action

.github/workflows/ci.yml
- uses: dtolnay/rust-toolchain@stable
  with:
    targets: aarch64-unknown-linux-musl

How to prevent it

  • Install every cross-target with rustup target add in CI setup.
  • Declare targets in the toolchain action so they’re always present.
  • Cache the toolchain so target components persist across runs.

Frequently asked questions

What causes Rust "error[E0463]: can't find crate for std" in CI?
There are 2 common causes: target std component not installed and a no_std-only or tier-3 target. Each cross-compilation target needs its own precompiled std (rust-std).
How do I fix Rust "error[E0463]: can't find crate for std" in CI?
There are 2 fixes depending on which cause you have: add the target’s std and request the target in the setup action. Work through them in order, since the first is the most common.
What does Rust "error[E0463]: can't find crate for std" in CI actually mean?
A --target build fails with error[E0463]: can't find crate for std (sometimes with a note that std isn’t available for the target).
How do I stop Rust "error[E0463]: can't find crate for std" in CI happening again?
Install every cross-target with rustup target add in CI setup. The prevention section lists 3 changes that keep it from recurring.
Can Latchkey fix this automatically?
Yes. Latchkey runs your GitHub Actions on managed runners that detect this failure, apply the fix, and retry the job automatically - self-healing is on by default.

Related guides

References

This is a setup failure, not a bug in your code. Latchkey detects, repairs, and retries it for you. Start free → 30-day trial · No credit card