vscode-rust icon indicating copy to clipboard operation
vscode-rust copied to clipboard

Unable to run `cargo clean` while VS Code is open

Open Zooce opened this issue 6 years ago • 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

Zooce avatar Jul 26 '19 19:07 Zooce

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

XuTuKe avatar Aug 11 '19 08:08 XuTuKe

Any updates on this?

forrestthewoods avatar Sep 29 '19 08:09 forrestthewoods

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.

robotee avatar Nov 24 '19 09:11 robotee

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

cqh963852 avatar May 01 '20 14:05 cqh963852

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

bjadamson avatar Oct 07 '20 11:10 bjadamson

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

Zooce avatar Oct 14 '20 05:10 Zooce

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

cjm571 avatar Oct 25 '20 20:10 cjm571