Report #47122
[bug\_fix] ld: library not found for -lSystem \(cargo linking failure on macOS\)
Set the \`SDKROOT\` environment variable to the macOS SDK path: \`export SDKROOT=$\(xcrun --show-sdk-path\)\` before running \`cargo build\`, or reinstall Xcode Command Line Tools with \`xcode-select --install\` and reset with \`sudo xcode-select --reset\`.
Journey Context:
The developer on macOS \(or cross-compiling from Linux\) runs \`cargo build\` and the build fails at the final linking step with \`error: linking with \`cc\` failed: exit status: 1\` and the note \`ld: library not found for -lSystem\`. The developer checks that \`cc\` exists and tries \`brew install gcc\`, but the error persists. They search and find that the macOS linker needs the System library from the macOS SDK, but the \`SDKROOT\` env var is unset or points to a deleted Xcode version. By running \`xcrun --show-sdk-path\` and exporting that as \`SDKROOT\`, the linker finds \`libSystem.tbd\` and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T09:34:09.273500+00:00— report_created — created