rust-analyzer: rust-analyser hangs at "Fetching", and uses CPU at 100%
rust-analyzer version: 0.3.1850 (latest at time of writing)
rustc version: rustc 1.78.0-nightly (3246e7951 2024-02-19)
System specs: Windows 10 Processor 11th Gen Intel® Core™ i7-11800H @ 2.30GHz 2.30 GHz Installed RAM 16,0 GB (15,8 GB usable) System type 64-bit operating system, x64-based processor
relevant settings:
Project is a bevy project setup as in this link https://bevyengine.org/learn/quick-start/getting-started/setup/ (I am using VSCode)
# Cargo.toml
[dependencies]
bevy = { version = "0.12.0", features = ["dynamic_linking"] }
# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3
# .cargo/config.toml
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe" # Use LLD Linker
rustflags = [
"-Zshare-generics=n",
"-Zthreads=0", # (Nightly) Use improved multithreading with the recommended amount of threads.
]
# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
[profile.dev]
debug = 1
# Rust analyser settings in vscode
"rust-analyzer.server.extraEnv": {
"CARGO_TARGET_DIR": "target/analyzer",
},
"rust-analyzer.check.extraArgs": [
"--target-dir=target/analyzer"
],
"rust-analyzer.cargo.extraEnv": {
"CARGO_PROFILE_RUST_ANALYZER_INHERITS": "dev",
"RUSTFLAGS": "-Clinker=rust-lld.exe"
},
"rust-analyzer.cargo.extraArgs": [
"--profile",
"rust-analyzer"
],
"rust-analyzer.check.overrideCommand": [
"cargo",
"clippy",
"--workspace",
"--message-format=json",
"--all-targets",
],
Like in the title, rust-analyser hangs at “Fetching” when starting the project, if I click on show logs it doesn’t show anything, but it keeps using the CPU with multiple rustc processes at 100%. I tried cleaning up the cache, reinstalling rust, messing with num thread and cache priming settings, but nothing worked.
The only thing that worked to make it usable was to revert to v0.3.1839, and now everything works fine. I will stay on that for now until it gets fixed 😃
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Reactions: 37
- Comments: 29 (13 by maintainers)
Commits related to this issue
- Auto merge of #16616 - Veykril:build-script-fix, r=Veykril fix: server hanging up on build script task This should fix https://github.com/rust-lang/rust-analyzer/issues/16614, can't say for certain ... — committed to rust-lang/rust-analyzer by bors 4 months ago
- Auto merge of #16645 - Veykril:deadlock, r=Veykril fix: Fix deadlock in `recreate_crate_graph` <-> `file_line_index` Fixes https://github.com/rust-lang/rust-analyzer/issues/16614 — committed to rust-lang/rust-analyzer by bors 4 months ago
Ah nevermind it is the two threads I think I found the problem
For the time being you can disable
rust-analyzer.cargo.buildScripts.rebuildOnSave, that should avoid the issue until a fix is landed I think.v0.4.1852 is still hanging for me :c
Full rebuild (Fetching…) on each save (“rust-analyzer.checkOnSave”: true). Extension version: v0.4.1856 (pre-release) Using Bevy 0.13 crate in project. Rust-analyser extension 0.3.1839 works fine. Am I do something wrong, or problem is still not solved?
Also affected. Fetching eventually finishes, but it easily takes half an hour. Afterwards it is responsive until I run a build on the command line (which, after rust-analyzer ran requires rebuilding half the application starting from proc_macro2, even if there were no changes). So it seems like rust-analzer invalidates regular builds and vice versa.
Reverting back to 0.3.1839 fixed the issue for me as well.