Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Windows: RLS keeping derive plugin DLLs opened prevents cargo build from working #802

Closed
mattico opened this issue Apr 1, 2018 · 1 comment

Comments

@mattico
Copy link

mattico commented Apr 1, 2018

Whenever the RLS is running for a crate, I can't do cargo build for that crate. It fails with errors like this:

error: linking with `C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.13.26128\bin\HostX64\x64\link.exe` failed: exit code: 1104
  |
  = note: <snip>"/DLL" "/IMPLIB:d:\\Code\\Rust\\bookshelf\\global-search\\target\\debug\\deps\\strum_macros-599a28c75e112151.dll.lib"
  = note: LINK : fatal error LNK1104: cannot open file 'd:\Code\Rust\bookshelf\global-search\target\debug\deps\strum_macros-599a28c75e112151.dll'


error: aborting due to previous error

error: Could not compile `strum_macros`.
warning: build failed, waiting for other jobs to finish...
error: linking with `C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.13.26128\bin\HostX64\x64\link.exe` failed: exit code: 1104
  |
  = note: <snip> "/DLL" "/IMPLIB:d:\\Code\\Rust\\bookshelf\\global-search\\target\\debug\\deps\\pest_derive-64cc25174a589cf5.dll.lib"
  = note: LINK : fatal error LNK1104: cannot open file 'd:\Code\Rust\bookshelf\global-search\target\debug\deps\pest_derive-64cc25174a589cf5.dll'


error: aborting due to previous error

error: Could not compile `pest_derive`.

To learn more, run the command again with --verbose.
The terminal process terminated with exit code: 101

Looking in Process Explorer, RLS has the derive plugin DLLs loaded. I assume this is what's causing cargo to fail, since it can't write to those files while they're loaded. Similarly, cargo clean fails:

λ cargo clean -p pest_derive
error: failed to remove build artifact

Caused by:
  failed to remove file `D:\Code\Rust\bookshelf\global-search\target\debug\deps\pest_derive-64cc25174a589cf5.dll`

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

If I close VSCode (and thus RLS), building with cargo build works fine again.

I assume this is Windows-specific due to its file exclusivity behavior. I think this started happening with a recent nightly (3/28?). I suppose this could've been caused by some change in cargo or rustc causing it to write to dlls which were already built or something.

@nrc
Copy link
Member

nrc commented Apr 5, 2018

This should be fixed on master, and in tomorrow's nightly. Please comment if not and I'll re-open.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants