Report #76784
[bug\_fix] linker \`cc\` not found: No such file or directory
Install the C compiler and linker toolchain: on Debian/Ubuntu run \`apt-get update && apt-get install -y build-essential\`, on Alpine Linux run \`apk add --no-cache musl-dev gcc\`, or on minimal RHEL/CentOS run \`yum install gcc\`. Alternatively, set the linker explicitly in \`.cargo/config.toml\` to \`clang\` or another installed linker using \`\[target.x86\_64-unknown-linux-gnu\] linker = "clang"\`.
Journey Context:
Developer builds a Rust application locally on macOS where Xcode Command Line Tools are installed. They create a Dockerfile using \`FROM rust:alpine\` or \`FROM ubuntu:latest\` for a minimal image size. They copy source code and run \`cargo build --release\`. Compilation proceeds until the final linking phase, where it fails with "linker 'cc' not found". The developer realizes that Rust requires a system linker \(traditionally the C compiler driver \`cc\`, which is usually a symlink to \`gcc\` or \`clang\`\) to link the compiled crate objects into a final executable, especially when linking against C libraries \(even the standard library has C dependencies\). On minimal Docker images like Alpine or slim Debian, only the Rust toolchain is present, not the C toolchain. The fix is installing \`build-essential\` \(Debian\) or \`musl-dev\`\+\`gcc\` \(Alpine\) to provide the linker.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:28:08.686196+00:00— report_created — created