rust-lang / rust-lang/rust-analyzer

Rust anaylzer fails to compile crates which build properly with `cargo build`

Open
#17,615 15 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

rust-analyzer version: (eg. output of "rust-analyzer: Show RA Version" command, accessible in VSCode via Ctrl/⌘+Shift+P)

0.3.2037-standalone (e9afba57a 2024-07-14)

rustc version: (eg. output of rustc -V)

rustc 1.79.0 (129f3b996 2024-06-10)

editor or extension: (eg. VSCode, Vim, Emacs, etc. For VSCode users, specify your extension version; for users of other editors, provide the distribution if applicable)

vscode

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)

none

===

I am on macos
I have a barebones cargo init project just with the uncased crate added in cargo.toml (the issue is not specific to this crate, it happens with others too)

cargo build runs just fine

but rust analyzer is unable compile it

2024-07-17T06:09:38.121175Z ERROR rust_analyzer::main_loop: FetchBuildDataError:
error: could not exec the linker `rust-lld.exe`
  |
  = note: Not a directory (os error 20)
  = note: env -u IPHONEOS_DEPLOYMENT_TARGET -u TVOS_DEPLOYMENT_TARGET -u XROS_DEPLOYMENT_TARGET LC_ALL="C" PATH="/nix/store/mm3mkpsyrkam2832ry5b3l0vnkd5967j-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/bin:/Users/ethan/.nix-profile/bin:/etc/profiles/per-user/ethan/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/opt/homebrew/bin:/Users/ethan/.npm-global/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:/Users/ethan/.config/zsh/plugins/powerlevel10k:/Users/ethan/.config/zsh/plugins/powerlevel10k-config" VSLANG="1033" ZERO_AR_DATE="1" "rust-lld.exe" "-flavor" "darwin" "-arch" "arm64" "-platform_version" "macos" "11.0" "11.0" "/var/folders/yv/wd8ppgks5wg0150bjf1yrxyr0000gn/T/rustc8ViwwR/symbols.o" "/Users/ethan/src/personal/tmp/rust-test/target/rust-analyzer/debug/build/uncased-18387905a62a1cca/build_script_build-18387905a62a1cca.build_script_build.94d5a8eee99c4963-cgu.0.rcgu.o" "/Users/ethan/src/personal/tmp/rust-test/target/rust-analyzer/debug/build/uncased-18387905a62a1cca/build_script_build-18387905a62a1cca.2m0u35fh66bvisgy.rcgu.o" "-L" "/Users/ethan/src/personal/tmp/rust-test/target/rust-analyzer/debug/deps" "-L" "/nix/store/mm3mkpsyrkam2832ry5b3l0vnkd5967j-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib" "/Users/ethan/src/personal/tmp/rust-test/target/rust-analyzer/debug/deps/libversion_check-f33dfa893f0af023.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libstd-7f95fd207255b41e.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-97393370543e3207.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libobject-a3d7c43b176960f9.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libmemchr-6371ee3a4bb27ae4.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-a7cf1a11761951bf.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libgimli-dad018a8d4ef8593.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-913776ff724458d1.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-364b04ba0ead75b3.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-918cdfbdd32cf1d1.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-424311e8ba1b9112.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libminiz_oxide-d4352744eff98311.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libadler-dd9df5b2170395b8.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libunwind-6b98b9caf95b8907.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-d4913584d9013c52.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/liblibc-04f062133e43a7ac.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/liballoc-5397ff6f88f2713a.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-5142793ba4eb4c05.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libcore-24a1e099f55e6f0d.rlib" "/nix/store/0jm39pz8p7d9qic4kaawwawhb56vaw2k-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-9ca5cbf9e98b80b9.rlib" "-lSystem" "-lc" "-lm" "-syslibroot" "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" "-L" "/nix/store/mm3mkpsyrkam2832ry5b3l0vnkd5967j-rust-stable-2024-06-13/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/ethan/src/personal/tmp/rust-test/target/rust-analyzer/debug/build/uncased-18387905a62a1cca/build_script_build-18387905a62a1cca" "-dead_strip"


error: aborting due to 1 previous error


error: could not compile `uncased` (build script) due to 2 previous errors

Im a bit confused how rust-lld.exe would ever be called on macos
any help is appreciated thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the barebones cargo-init project and the uncased dependency, comparing cargo build with rust-analyzer's build-data collection. Start from the rust_analyzer::main_loop FetchBuildDataError and inspect why the macOS invocation selects rust-lld.exe. Done means rust-analyzer can compile the project without the linker error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.