Open brandonson opened 7 months ago
The json output format of cargo test is unstable, so we use RUSTC_BOOTSTRAP=1
to enable it. Some popular dependencies require a rebuild when this environment variable changes. As a workaround, you can set RUSTC_BOOTSTRAP=1
everywhere to avoid the rebuild, including the terminal you run cargo test
and in rust-analyzer.cargo.extraEnv
As a brand-new Rust / VS Code user, I am also affected by this painful issue. My settings.json
is set as follows, which assists with this problem:
{
"rust-analyzer.cargo.extraEnv": {
"RUSTC_BOOTSTRAP": "1",
},
"rust-analyzer.runnables.extraEnv": {
"RUSTC_BOOTSTRAP": "1",
},
"rust-analyzer.testExplorer": true,
"rust-analyzer.cargo.targetDir": true
}
I don't know if this is the optimal configuration, but it definitely helps. I also set the RUSTC_BOOTSTRAP
environment variable when running cargo commands from the CLI.
I really don't have other interest in using nightly features, and don't want to accidentally start using them in my code, so hopefully this extension will soon be able to avoid the use of this environment variable. The status quo is not the best out-of-box experience.
The tracking issue for stablizing it in compiler is https://github.com/rust-lang/testing-devex-team/issues/1
Note that you won't accidentally use unstable features since they are gated behind #[feature] or --Zunstable, though your dependencies can intentionally use unstable features without you being noticed.
+1 - this basically makes the test explorer unusable by default on medium - large projects. Until I found the RUSTC_BOOTSTRAP workaround I had to do a full rebuild every time I rebooted my machine.
rust-analyzer version: rust-analyzer version: 0.3.1932-standalone (47a901b9b 2024-04-21)
rustc version: 1.77.2
editor or extension: VSCode Insiders with RA 0.3.1932
It's pretty common for running tests via the Test Explorer to require a full rebuild of all dependencies. Seems like build results are getting trampled and lost when check runs. That is, the common
test - fix/save file - test - fix/save file
loop seems to require a rebuild of everything at every step.Seems to happen regardless of
rust-analyzer.cargo.targetDir
being set to true or not. However,"rust-analyzer.check.extraArgs": ["--target-dir", "rust-analyzer-check"]
seems to mitigate it, but runningcargo test
from the CLI requires and forces a full rebuild.