Skip to content

VSCode Test Explorer regularly requires a full rebuild #17149

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

Open
brandonson opened this issue Apr 27, 2024 · 4 comments
Open

VSCode Test Explorer regularly requires a full rebuild #17149

brandonson opened this issue Apr 27, 2024 · 4 comments
Labels
A-test-explorer Issues related to the test explorer lsp extension and vscode test api C-bug Category: bug

Comments

@brandonson
Copy link

brandonson commented Apr 27, 2024

rust-analyzer version: rust-analyzer version: 0.3.1932-standalone (47a901b 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 running cargo test from the CLI requires and forces a full rebuild.

@brandonson brandonson added the C-bug Category: bug label Apr 27, 2024
@HKalbasi HKalbasi added the A-test-explorer Issues related to the test explorer lsp extension and vscode test api label Apr 27, 2024
@HKalbasi
Copy link
Member

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

@JohnstonJ
Copy link

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.

@HKalbasi
Copy link
Member

The tracking issue for stablizing it in compiler is rust-lang/testing-devex-team#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.

@pcone
Copy link

pcone commented Oct 1, 2024

+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.

davidB added a commit to cdviz-dev/cdviz-collector that referenced this issue Jan 20, 2025
workaround to reduce cli full rebuild / conflict with rust-analyzer (see [VSCode Test Explorer regularly requires a full rebuild · Issue #17149 · rust-lang/rust-analyzer](rust-lang/rust-analyzer#17149))
davidB added a commit to cdviz-dev/cdviz-collector that referenced this issue Jan 20, 2025
workaround to reduce cli full rebuild / conflict with rust-analyzer (see [VSCode Test Explorer regularly requires a full rebuild · Issue #17149 · rust-lang/rust-analyzer](rust-lang/rust-analyzer#17149))
davidB added a commit to cdviz-dev/cdviz-collector that referenced this issue Jan 20, 2025
workaround to reduce cli full rebuild / conflict with rust-analyzer (see [VSCode Test Explorer regularly requires a full rebuild · Issue #17149 · rust-lang/rust-analyzer](rust-lang/rust-analyzer#17149))
@zaneduffield zaneduffield marked this as a duplicate of #17121 Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-test-explorer Issues related to the test explorer lsp extension and vscode test api C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

4 participants