rust-lang / vscode-rust

Rust extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=rust-lang.rust
Other
1.39k stars 167 forks source link

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

Open Zooce opened 5 years ago

Zooce commented 5 years ago

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

XuTuKe commented 5 years ago

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

forrestthewoods commented 5 years ago

Any updates on this?

robotee commented 5 years ago

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.

cqh963852 commented 4 years ago

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

bjadamson commented 4 years ago

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

Zooce commented 4 years ago

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

cjm571 commented 4 years ago

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