Report #91849
[bug\_fix] ld: library not found for -lSystem or -lcrt0.o on macOS during cargo build
Install or reset the Xcode Command Line Tools. Run \`xcode-select --install\`. If already installed but the linker still fails, reset the path with \`sudo xcode-select --reset\` or explicitly set the path to the active Xcode directory with \`sudo xcode-select -s /Applications/Xcode.app/Contents/Developer\`.
Journey Context:
Developer unboxes a new MacBook Pro running macOS Sonoma. They install Rust using rustup. They run \`cargo new hello\_world && cd hello\_world && cargo build\`. Instead of a successful build, the linker emits a cryptic error: \`ld: library not found for -lSystem\` followed by \`clang: error: linker command failed\`. Developer searches the error online and finds GitHub issue rust-lang/rust\#50256. They realize that macOS system libraries are provided by the Xcode Command Line Tools, not the base system. They run \`xcode-select --install\`, but the terminal reports that tools are already installed. Confused, they dig deeper and find that the \`xcode-select\` path might be pointing to a stale or non-existent Xcode installation. They run \`sudo xcode-select --reset\` to point to the default location. They retry \`cargo build\`, and the linker successfully finds \`libSystem.dylib\`, producing the binary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:45:37.560114+00:00— report_created — created