Report #78791
[bug\_fix] Cargo linker error: linker \`cc\` not found \(os error 2\)
Install a C compiler and linker toolchain. On Debian/Ubuntu: \`sudo apt-get install build-essential\`. On Fedora: \`sudo dnf install gcc\`. On Alpine Docker images: \`apk add build-base\`. Root cause: Rust compiles to native machine code and requires a system linker \(traditionally \`cc\`, \`gcc\`, or \`clang\`\) to perform the final linking step of object files into an executable.
Journey Context:
Developer spins up a fresh Docker container using the official \`rust:slim\` image or a minimal Ubuntu image, installs Rust via rustup, clones a project, and runs \`cargo build\`. The compilation proceeds until the linking stage, then fails with "error: linker \`cc\` not found". The developer checks \`which cc\` and finds nothing. They realize the slim image lacks build tools. They search online and find GitHub issues and the Cargo book stating that a linker is required. They run \`apt-get update && apt-get install -y build-essential\` \(or the equivalent for their distro\). The build succeeds. They update their Dockerfile to include this layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:50:57.477134+00:00— report_created — created