Vscode-rust: Unable to run `cargo clean` while VS Code is open

Created on 26 Jul 2019  路  7Comments  路  Source: rust-lang/vscode-rust

Running cargo clean while VS Code was open (with a Rust project), I got the following error:

$ cargo clean
error: could not remove build directory

Caused by:
  failed to remove file `<path to my project>\target\rls\debug\deps\serde_derive-7eec45f9b1b97ee6.dll`

Caused by:
  Access is denied. (os error 5)

I tried this several times, and every time access was denied. I closed VS Code and ran cargo clean again, and it worked immediately. Maybe the rls-vscode plugin is holding onto some files, preventing cargo clean from removing them?

_VS Code Info_
Version: 1.37.0-insider (user setup)
Commit: 6d82826e990407364d5c829b73602a19ecdf7d00
Date: 2019-07-26T05:37:26.606Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.16299

Most helpful comment

It appears that (on Windows 10 with VS Code at least) RLS is at fault.

I was able to work around the issue by stopping the server via Command Palette -> "Rust: Stop the Rust server". cargo clean ran without error while the server was stopped, and then I started the server again.

Not a great workaround, since RLS has to churn through all your source again, but I haven't seen any other fixes/workarounds for this.

VS Code Info
Version: 1.50.1 (user setup)
Commit: d2e414d9e4239a252d1ab117bd7067f125afd80a
Date: 2020-10-13T15:06:15.712Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19042

All 7 comments

Running cargo clean while VS Code was open (with a Rust project), I got the following error:

$ cargo clean
error: could not remove build directory

Caused by:
  failed to remove file `<path to my project>\target\rls\debug\deps\serde_derive-7eec45f9b1b97ee6.dll`

Caused by:
  Access is denied. (os error 5)

I tried this several times, and every time access was denied. I closed VS Code and ran cargo clean again, and it worked immediately. Maybe the rls-vscode plugin is holding onto some files, preventing cargo clean from removing them?

_VS Code Info_
Version: 1.37.0-insider (user setup)
Commit: 6d82826e990407364d5c829b73602a19ecdf7d00
Date: 2019-07-26T05:37:26.606Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.16299

I have the same problem

Any updates on this?

This issue is not only related to VS code, I had the same problem with sublime. The issue i had was caused due to the editor was reading user input. And since sublime doesn't support input console the process was hang. So what i did on Windows is i opened the task manager (ctrl+shift+esc) and then i ended the (guessing_game.exe) task that was running under sublime editor.

Capture

As for VS code if it's the same issue as mine then you can easily terminate the task
in the menu bar go to (Terminal->Terminate task..).
Now cargo clean should work.

I meet the same problem,But I am using docker container development environment.
image

I'm running into this trying to get started using rust :(

BTW: This does not happen on my Pop!_OS 20.04 machine. Maybe a Windows-only issue? Maybe that will help narrow things down a bit...

It appears that (on Windows 10 with VS Code at least) RLS is at fault.

I was able to work around the issue by stopping the server via Command Palette -> "Rust: Stop the Rust server". cargo clean ran without error while the server was stopped, and then I started the server again.

Not a great workaround, since RLS has to churn through all your source again, but I haven't seen any other fixes/workarounds for this.

VS Code Info
Version: 1.50.1 (user setup)
Commit: d2e414d9e4239a252d1ab117bd7067f125afd80a
Date: 2020-10-13T15:06:15.712Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19042

Was this page helpful?
0 / 5 - 0 ratings