The process cannot access the file because it is being used by another process. (os error 32)

Hi,
We are facing some issue on our project running cargo build or cargo test can cause the following error

error: failed to build archive at C:\Users\lucianopa\Documents\my_project\target\x86_64-pc-windows-msvc\debug\deps\libmyproject.rlib: failed to remove temporary directory: The process cannot access the file because it is being used by another process. (os error 32) at path "C:\Users\lucianopa\Documents\ my_project\target\x86_64-pc-windows-msvc\debug\deps\.tmpB3EUxx.temp-archive"

The issue is flaky but less likely to happen if we specify --jobs 1

It does looks like some issue with cargo but my question would be what are those .temp-archive for and if we are doing something in our configuration that makes this error happen or more likely?
Also if there would be any tips on how to debug this further?

Thanks,
Luciano Almeida

First guess would be antivirus.

Figure out what is using the file. (Sure there was a sysinternals app that could help but been too long since I looked.)

1 Like

The .temp-archive directory is where the rlib is written to first before getting moved to the final location to prevent reading a partially written rlib.

1 Like