rust-analyzer picks on crates used in build.rs (error[E0514]) while "cargo build", builds project just fine
I receive this message from PROBLEMS section of vscode:
found crate
cccompiled by an incompatible version of rustc rustc(Click for full compiler diagnostics) the following crate versions were found: cratecccompiled by rustc 1.90.0 (1159e78c4 2025-09-14): /Users/samadariyan/Learning/embedded- rust/Exercises/flappy_bird_ffi/target/debug/deps/libcc-89fccd86b939197f.rlib please recompile that crate using this compiler (rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)) (consider runningcargo cleanfirst)
and after click on " rustc(Click for full compiler diagnostics)" it. shows this:
error[E0514]: found crate
cccompiled by an incompatible version of rustc --> build.rs:9:22 | 9 | let mut builder: cc::Build = cc::Build::new(); | ^^ | = note: the following crate versions were found: cratecccompiled by rustc 1.90.0 (1159e78c4 2025-09-14): /Users/samadariyan/Learning/embedded-rust/Exercises/flappy_bird_ffi/target/debug/deps/libcc-89fccd86b939197f.rlib = help: please recompile that crate using this compiler (rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)) (consider runningcargo cleanfirst)
But the project builds just fine with the command: 'cargo build' because cc crate is used in build.rs, and it's normal to compile against the host toolchain while my project compiles against "thumbv7em-none-eabihf"
rust-analyzer version: Identifier rust-lang.rust-analyzer Version 0.3.2593
rustc version: rustc 1.90.0 (1159e78c4 2025-09-14)
editor or extension: VSCode Version: 1.104.1
relevant settings: rustup show: Default host: x86_64-apple-darwin rustup home: /Users/samadariyan/.rustup
installed toolchains
stable-x86_64-apple-darwin (active, default)
active toolchain
name: stable-x86_64-apple-darwin active because: it's the default toolchain installed targets: thumbv7em-none-eabihf x86_64-apple-darwin cargo home: /Users/samadariyan/.cargo
repository link (if public, optional): Owner avatar flappy-bird-ffi
code snippet to reproduce:
cc::Build::new();
Same story with clippy
This diagnostic comes from rustc, not rust-analyzer, so something is wrong with your setup, not with r-a.
Try running cargo check --workspace. Also, do you have special r-a settings?
I put build.rs in the exception list:
{ "rust-analyzer.files.exclude": ["build.rs", "/build.rs"], }
cargo check --workspace:
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s
@ChayimFriedman2 Even changed rust toolchain to 1.88.0, but the same message
I guess r.a checkin cc crate againest build target, And for the environment, I tried uninstalling from rustup self-uninstall and installed everything again.
And here results of "1.88.0" toolchain:
crate cc compiled by rustc 1.88.0 (6b00bc388 2025-06-23): /Users/samadariyan/Learning/embedded-rust/flappy-bird-ffi/target/debug/deps/libcc-3aeac5ea6784feef.rlib = help: please recompile that crate using this compiler (rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)) (consider running cargo clean first)
error is showing same version and same hash and same date! but asking to re-compile.
I'll check on this
@ShoyuVanilla I've made a bare minimum project and
cargo check
and
cargo build
works fine but with
cargo clippy
I receive same error
➜ empty-rust git:(main) ✗ cargo clippy Compiling empty-rust v0.1.0 (/Users/samadariyan/Learning/empty-rust) error[E0514]: found crate
cccompiled by an incompatible version of rustc --> build.rs:2:19 | 2 | let builder = cc::Build::new(); | ^^ | = note: the following crate versions were found: cratecccompiled by rustc 1.90.0 (1159e78c4 2025-09-14): /Users/samadariyan/Learning/empty-rust/target/debug/deps/libcc-f2b71ba11f1f4946.rlib = help: please recompile that crate using this compiler (rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)) (consider runningcargo cleanfirst)For more information about this error, try
rustc --explain E0514. error: could not compileempty-rust(build script) due to 1 previous error
I hope this info helps repo link empty-rust
Sorry guys @ShoyuVanilla and @ChayimFriedman2 , I. found rustc 1.88.0 was installed using mac ports and that was the source of the issue, which cost me a month and searching the whole system from root to find it.