Report #9658
[bug\_fix] linker \`cc\` not found: No such file or directory \(os error 2\)
Install the system C development toolchain: on Debian/Ubuntu run \`sudo apt-get install build-essential\`, on RHEL/CentOS \`sudo dnf install gcc\`, on macOS install Xcode Command Line Tools.
Journey Context:
Developer provisions a fresh Ubuntu 22.04 LTS cloud server and installs Rust via rustup using the official script \(\`curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh\`\). They create a new project with \`cargo new demo\` and immediately run \`cargo build\`. Instead of compiling, the build fails with: "error: linker \`cc\` not found". Developer checks if gcc is installed \(\`gcc --version\`\) and finds it missing. They try \`sudo apt install gcc\` which installs the compiler but not the headers or make. Running \`cargo build\` again yields a different linker error about missing \`ld\` or crti.o. Developer searches StackOverflow and finds advice to install \`build-essential\` rather than just \`gcc\`. They run \`sudo apt-get install build-essential\` which installs gcc, g\+\+, make, and libc development headers. Running \`cargo build\` now succeeds. The fix works because Rust uses the system C linker \(\`cc\`, which is usually a symlink to gcc or clang\) to link the compiled Rust code with the standard library and platform system libraries. Without the C toolchain, the final linking stage cannot complete.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T08:45:19.160247+00:00— report_created — created