rust-analyzer: vscode + rust analyzer close rustc processes on exit

Quitting vscode leaves some running rustc/cargo jobs holding a lock on the build directory. Requires a manual kill to stop them.

Environment:

Version: 1.46.1
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:17:14.222Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 17.7.0
Name: rust-analyzer
Id: matklad.rust-analyzer
Description: An alternative rust language server to the RLS
Version: 0.2.232
> ~/Library/Application\ Support/Code/User/globalStorage/matklad.rust-analyzer/rust-analyzer-mac --version
rust-analyzer 8b0983e

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 4
  • Comments: 25 (16 by maintainers)

Most upvoted comments

Windows also has Job Objects for this. But it’s not clear to me why this is actually a problem. Doesn’t rustc finish by itself in a couple of seconds? Does it hang if cargo died?

You have to be patient for rustc to finish compiling.

Same here. Happens a lot. Getting crazy from this. Happy to debug. I just killed like 20 hanging cargo commands that were spun up by rust-analyzer.

EDIT: Running on OSX. This happens on 2 different machines. One is Intel based and one is ARM based.

for *those building on substrate, these settings have helped to lessen the problem for me

    "rust-analyzer.cargo.runBuildScripts": false, <-- don't run the wasm build every time
    "rust-analyzer.checkOnSave.allTargets": false, <-- don't run test build every time

Also this is happening when this happens. Screenshot 2021-04-19 at 14 20 14

One more note from me. I use format on save in vscode which runs rustfmt. It happens when cargo check or formatter is running and I press save again, not sure exactly at which point. It looks like the processess interlock each other and never finish. Is it possible that they both try to file lock and stay running indefinitly because of that?

Looks like when I save the old cargo process is not killed

I can easily repeat by loading large project and smashing cmd+s multiple times on different osx machines.

image

This one definitely happens for me a lot. Not sure if it’s something about my setup, but I frequently have to kill cargo processes before rust-analyzer starts working in VSCode; it just hangs waiting for the file lock otherwise. Would be great to resolve.