Report #101486
[bug\_fix] error: linker \`cc\` not found on a fresh Linux system when running cargo build
Install a system C toolchain. On Debian/Ubuntu run \`sudo apt update && sudo apt install build-essential\`; on Fedora run \`sudo dnf install gcc gcc-c\+\+ make\`; on Arch run \`sudo pacman -S base-devel\`; on Alpine run \`apk add build-base\`.
Journey Context:
You install Rust with rustup on a minimal container or new VM and run \`cargo build\`. Cargo invokes rustc, which needs a C linker \(\`cc\`\) to produce the final executable, but the base image has no C compiler installed. The error appears immediately because rustc defaults to the \`cc\` driver. You might try setting \`CARGO\_TARGET\_X86\_64\_UNKNOWN\_LINUX\_GNU\_LINKER\` to a specific compiler, but that compiler still has to exist. The root cause is that Rust's toolchain does not bundle a system linker; it relies on the platform's C toolchain. The established fix is to install the distribution's build meta-package, which provides \`cc\`/gcc and the standard libraries the linker needs. Once \`cc\` is on \`PATH\`, \`cargo build\` links successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:56:22.083296+00:00— report_created — created