Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

Rust E0463: can't find crate for std

The target triple has no standard library installed. Add the target with rustup, check the target string and link the right ABI.

~5 min readRust
#rust#targets#cross-compilation#compiler-errors
Bold white headline reading E0463 beside a cyan Rust crate missing its amber target slice.

Introduction & Quick Summary

A cross-compilation build fails before compiling a single line of your code:

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

Quick answer: the standard library is compiled per target, and the target you asked for has no std rlib available to the compiler. Either the target is not installed in the active toolchain, or the target genuinely has no standard library (bare-metal targets). The first case is one rustup command; the second is a #![no_std] project.

bash
rustup target list --installed rustup target add wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown --release

The note under the error names the target, which is the piece of information the message itself leaves out. This guide covers how the toolchain stores targets, what to do when rustup is not the toolchain in use, which targets have no std at all, and how -Z build-std and cross fit in when the prebuilt path does not exist.

Core Mechanics, Signatures & Reproducible Setup

A Rust toolchain ships the compiler, cargo, rustdoc, and the standard library for one or more targets. The host target (x86_64-unknown-linux-gnu, aarch64-apple-darwin) always has std; additional targets are installed separately as .rlib files for that triple.

bash
rustup show # Rustup home: /Users/ryu/.rustup # active toolchain # stable-aarch64-apple-darwin (default) # rustc 1.83.0 # installed targets: # aarch64-apple-darwin # x86_64-unknown-linux-gnu

cargo build --target <triple> looks for std for that triple inside the active toolchain's lib/rustlib/<triple>/lib. If the directory is missing, the compiler reports E0463 with the note shown above.

bash
ls "$(rustc --print sysroot)/lib/rustlib" # aarch64-apple-darwin components manifest-* ... rustup target add aarch64-unknown-linux-gnu ls "$(rustc --print sysroot)/lib/rustlib" # aarch64-apple-darwin aarch64-unknown-linux-gnu components ...

A reproducible case:

bash
cargo new --lib demo && cd demo cargo build --target wasm32-unknown-unknown # error[E0463]: can't find crate for `std` rustup target add wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown # Compiling demo v0.1.0 ... Finished

rustc --print target-list lists every triple the compiler knows; rustup target list lists the ones with prebuilt std.

Key Comparison Table

Target tripleHas prebuilt stdTypical use
x86_64-unknown-linux-gnuyesservers
aarch64-unknown-linux-gnuyesarm64 servers, containers
wasm32-unknown-unknownyes, without threads and filesbrowser modules
wasm32-wasip1yesWASI runtimes
thumbv7em-none-eabihfnoembedded Cortex-M
aarch64-unknown-nonenobare-metal arm64
riscv32imac-unknown-none-elfnoembedded RISC-V
SituationRight fixCommand
target not installedadd itrustup target add <triple>
target has no std#![no_std] cratenone
need std on a no-std targetnightly build-stdcargo +nightly build -Z build-std=std,panic_abort --target <triple>
distro rustc without rustupinstall rustup toolchainrustup toolchain install stable
linker missing after the fixinstall a cross linkerapt install gcc-aarch64-linux-gnu
CI image without targetsadd targets in the imagerustup target add ... in Dockerfile
Error variantMeaningNext step
note names a targettarget not installedrustup target add
note says target does not support stdno-std targetswitch crate to no_std
error appears only in Dockerimage uses a different toolchaincheck rustc --version in the image
error after rustup overrideoverride points at a toolchain without the targetrustup target add in that toolchain

Practical Edge Cases, Error Fixes & Deep Dive Code Examples

1. Confirm that rustup is the toolchain in use

Distribution packages (apt install rustc, brew install rust) do not use rustup, so rustup target add fails with "no installed toolchains" or adds the target to a toolchain the build never runs:

bash
which -a rustc cargo rustup rustc --version rustup show active-toolchain

If which rustc points at /usr/bin/rustc while rustup manages ~/.cargo/bin, either remove the distribution package or pin the path. CI images built with a slim Debian base often hit exactly this: rustup is absent, the compiler is the distro one, and no target can be added until rustup is installed.

2. Toolchain overrides and rust-toolchain.toml

A rust-toolchain.toml in the repository selects a toolchain for that directory, and each toolchain has its own target list. Adding a target to stable does not add it to the 1.75 pinned by the file:

toml
[toolchain] channel = "1.83.0" targets = ["wasm32-unknown-unknown"] components = ["rustfmt", "clippy"]

Declaring targets here is the most reliable fix for teams and CI, because rustup installs them automatically when the directory is entered. Without the declaration, every new machine repeats the same failure.

3. WASM targets and their std

wasm32-unknown-unknown has std with limits: no threads by default, no filesystem, no system clock. Code that compiles natively can still fail after the target is installed, with a different error about unsupported APIs.

bash
rustup target add wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown # later: error: no method named `spawn` found for struct `std::thread::Builder`

For server-side WASM, wasm32-wasip1 is the current name (it was wasm32-wasi until Rust 1.78); installing the old name on a new toolchain produces a "target not found" message rather than E0463. Confirm the name against rustup target list | grep wasm.

4. Bare-metal targets have no std at all

Targets ending in -none- or -none-eabi* do not ship std. Adding them with rustup succeeds for core and alloc, and the crate must opt out:

rust
#![no_std] #![no_main] use core::panic::PanicInfo; #[panic_handler] fn panic(_info: &PanicInfo) -> ! { loop {} } #[no_mangle] pub extern "C" fn add(a: i32, b: i32) -> i32 { a + b }

A binary crate for such a target also needs an entry point (usually from a runtime crate such as cortex-m-rt) and a linker script. Compiling ordinary std code for thumbv7em-none-eabihf cannot work by installing anything; the platform has no operating system for std to call.

5. -Z build-std when no prebuilt std exists

For a target with no published std (a custom JSON target, a new architecture, x86_64-unknown-none), nightly can build the standard library from source:

bash
rustup +nightly component add rust-src cargo +nightly build -Z build-std=core,alloc --target my-target.json --release

Include std in build-std only if the target can support it; for bare metal, core plus alloc is the realistic set. This is a nightly feature, so it belongs in a CI job pinned to a nightly date rather than in a stable build.

6. Cross linkers and cross

Installing the target provides std; linking still needs a linker for that platform. On Linux hosts:

bash
sudo apt install gcc-aarch64-linux-gnu cat >> ~/.cargo/config.toml <<'EOF' [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" EOF

The cross tool packages this in a container and is often faster than configuring linkers by hand. After a successful build, compare the resulting binaries or manifests with the diff checker when a container image starts failing only after a toolchain bump, and keep the relevant environment values in a checked file with the environment variable formatter.

Common Compilation/Runtime Mistakes & Version Gotchas

  • Adding the target to the wrong toolchain. rustup target add applies to the active toolchain; a pinned rust-toolchain.toml or a rustup override selects a different one.
  • Expecting std on -none- targets. The error is correct; the crate needs #![no_std].
  • Assuming the host target needs installing. It is always present; an E0463 on the host target points at a corrupted toolchain (reinstall it) or a wrong --sysroot.
  • Ignoring the linker. E0463 replaced by linker 'cc' not found means the target is installed and the cross toolchain is not.
  • Version notes. wasm32-wasi became wasm32-wasip1 in Rust 1.78, with the old name kept for a transition period; scripts that pin the old name break on newer toolchains. -Z build-std remains nightly-only.
  • Docker caches. A layer that runs rustup target add before COPY keeps working; one that runs it in a later stage does not affect the earlier build stage.

Official documentation: E0463 and the rustup cross-compilation guide.

Official references

primary documentation

The Rust documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Rust work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Rust guides

More in Rust

All Rust guides

The guides filed next to this one in Rust, in library order.