Closed
Description
When trying to run rustc
for the first time on MacOS X, you might encounter this error message:
error: linking with cc failed: exit code: 1
|
= note:
"cc"
"-m64"
"-arch"
"x86_64"
"-L"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib"
"main.main.7rcbfp3g-cgu.0.rcgu.o"
"main.main.7rcbfp3g-cgu.1.rcgu.o"
"main.main.7rcbfp3g-cgu.2.rcgu.o"
"main.main.7rcbfp3g-cgu.3.rcgu.o"
"main.main.7rcbfp3g-cgu.4.rcgu.o"
"main.main.7rcbfp3g-cgu.5.rcgu.o"
"main.main.7rcbfp3g-cgu.6.rcgu.o"
"main.main.7rcbfp3g-cgu.7.rcgu.o"
"-o"
"main"
"main.4s37gsrti678ik8u.rcgu.o"
"-Wl,-dead_strip"
"-nodefaultlibs"
"-L"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-349f286494d73b18.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-0c9fcc24a503d489.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libobject-70419d92d1ba4b1d.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libaddr2line-65e88774cb68bd46.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libgimli-3849b3781a19a398.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-0dbb03fa66ca6d84.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-65edff8661311c85.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-599e707cd7ee7216.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-40cb05f6c516791a.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-7a0a923a4d37a048.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-7e047938e88325ef.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-02542d835be27c0f.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-63712b18a1365082.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-1196a2a060497e71.rlib"
"/Users/z/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-10db70d883838cbc.rlib"
"-lSystem"
"-lresolv"
"-lc"
"-lm"
= note: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
This happens if you haven't installed the Developer Command Line Tools with xcode-select --install
.
We should detect the error output message "missing xcrun" and when it happens, emit a more targeted, friendlier error explaining what happened to the user.
Taken from https://users.rust-lang.org/t/error-compiling-my-first-basic-rust-program/58872