Report #40359
[bug\_fix] linker \`cc\` not found: No such file or directory \(os error 2\)
Install the system C compiler and linker toolchain: \`sudo apt install build-essential\` on Debian/Ubuntu, \`sudo pacman -S base-devel\` on Arch, or \`sudo dnf install gcc\` on Fedora. Root cause: Cargo invokes the platform linker \(typically \`cc\` or \`gcc\`\) to link Rust crates, the standard library, and any native dependencies, even for pure Rust projects.
Journey Context:
Developer sets up a fresh WSL2 Ubuntu instance or minimal Docker container, installs Rust via rustup \(which provides rustc and cargo\). They create a new project with \`cargo new demo\` and immediately run \`cargo build\`. Instead of success, they get a hard error stating the linker \`cc\` was not found. They verify \`cc\` is missing with \`which cc\`. Searching the error online leads to GitHub issues and StackOverflow explaining that Rust requires a C toolchain for linking. They run \`sudo apt update && sudo apt install build-essential\`, which installs \`gcc\`, \`make\`, and \`cc\` \(symlinked to gcc\). Running \`cargo build\` again successfully compiles the binary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T22:12:53.685729+00:00— report_created — created