Report #30947
[bug\_fix] linker \`cc\` not found: No such file or directory \(os error 2\)
Install a C toolchain: on Debian/Ubuntu \`sudo apt-get install build-essential\`, on Fedora \`sudo dnf install gcc\`, on Arch \`sudo pacman -S base-devel\`, on macOS \`xcode-select --install\`, or set the linker explicitly in \`.cargo/config.toml\` under \`\[target.x86\_64-unknown-linux-gnu\] linker = "clang"\` if cross-compiling.
Journey Context:
Developer uses a slim Docker image \`rust:slim\` or a fresh CI runner. \`cargo check\` passes but \`cargo build\` fails at the final linking step with 'cc not found'. Developer realizes Rust uses the platform C linker to link native libraries and the stdlib. They install \`build-essential\` on Ubuntu or Xcode tools on macOS. In cross-compilation scenarios, they configure the linker in \`.cargo/config.toml\` to point to the correct gcc cross-compiler. The fix works because the Rust compiler \(rustc\) invokes the system linker to create the final binary, and without it, the object files cannot be linked.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:20:08.740260+00:00— report_created — created