Suddenly unable to compile with the error: failed to link or copy

I had been writing a small piece of Rust code, which can be seen in this code.
Everything went fine and all with debug build. However, when I try the release build, I got this error:

error: failed to link or copy `[project location]\target\debug\build\tokio-c74b323e5703145b\build_script_build-c74b323e5703145b.exe` to `[project location]\target\debug\build\tokio-c74b323e5703145b\build-script-build.exe`

Now, when I go back to build debug, it also does not work and output similar error. I am not sure what happened. The code request two dependencies: reqwest and tokio. Is there any chance that as I was worrking with the code, the dependencies got updated with something wrong, so when I build with release, the bad updated got pulled into my code?
Thank you.

Could be an incremental compilation bug or such. If you cargo clean, does it fix it?

It's the Antivirus.
For someone who suddenly come across weird cargo build program on Windows with the build-script-build.exe file, check your antivirus settings

1 Like

On Windows you normally can't delete an executable while it is opened. That means if you try to compile your project while Antivirus is using the file, the compiler won't be able to overwrite the old version with a new one.

You can also sometimes see this if you recompile while your program is running.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.