-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust-analyzer can invoke build scripts with RUSTC_BOOTSTRAP=1
, wreaking havoc on feature detection
#15057
Comments
Got same error when At the same time, I use Try below does not working.
Then
Now seems working correctly. |
Yes, recent project, maybe 1~2 weeks. Old cache deleted, did not backup for reproduce. |
Now, I try with "rust-analyzer.cargo.buildScripts.useRustcWrapper": true,
"rust-analyzer.rust.analyzerTargetDir": "{{RA_TARGET}}" Guess in this way will not pollute real build cache forever. Hope will not happen again. |
It works fine for me without changing any settings. Are you sure you're not running a very old version of RA? And please try in an empty project (with |
RA FYI. I depend on Background, rust newbie. |
This should be fixed? |
This issue isn't fixed yet. I posted PR #16621 to fix it. |
fix: Recompiles due to RUSTC_BOOTSTRAP Some packages (e.g. thiserror) force a recompile if the value of the `RUSTC_BOOTSTRAP` env var changes. RA sets the variable to 1 in order to enable rustc / cargo unstable options. This causes flapping recompiles when building outside of RA. Fixes #15057
rust-analyzer version: 0.3.1541
rustc version: rustc 1.70.0 (90c541806 2023-05-31)
relevant settings:
"rust-analyzer.cargo.buildScripts.useRustcWrapper": false,
Some crates (for instance anyhow and thiserror) determine whether they are being built by a supported nightly compiler by performing a trial compilation in their build script (think autotools). It seems like rust-analyzer will invoke build scripts while having
RUSTC_BOOTSTRAP
set (perhaps only under some circumstances), which makes those crates think they can use nightly features.This appears to "work" in rust-analyzer, and "poisons" the build cache with the build script output. A later
cargo run
in the terminal will then reuse the build script output, and build the crate in question without havingRUSTC_BOOTSTRAP
set, leading to errors like this:This has previously been reported in dtolnay/thiserror#192 as affecting users that have
rust-analyzer.cargo.buildScripts.useRustcWrapper
enabled (the default), while I have it disabled, so it seems that the setting may be a red herring and doesn't matter.The text was updated successfully, but these errors were encountered: