Cargo - failed to link or copy

Hy I'm new to Rust and currently working through the "Book" but there's something with Cargo that's a little bit annoying. Sometimes, when I make a new project and run it the first time with cargo run, everything's fine but when I make a small change to the code after that and run it again I get an error:


error: failed to link or copy C:\...\rust_projects\learning_rust\branches\target\debug\deps\branches-14bae1fca06ad47d.exe to C:\...\rust_projects\learning_rust\branches\target\debug\branches.exe

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


The .exe file under \debug disappears and I'm also not able to for example delete the folder even as admin. A restart solves the problem with the permission but it's still annoying to be forced to create the project again, copy and paste the code and so on.

Using cargo build instead of run had no effect. I'm using Windows 10. Maybe someone of you had a similar issue and could help me understand what causes the problem.

I only have a quick suggestion: it could be that your anti virus / malware software is the culprit.

At home I use Bitdefender and until you whitelist an application it could be that they think that it is malware and block it. You can look in the log of your antivirus and you will see if they blocked it.

Bitdefender is blocking per default rustup update and the TeXLive update manager as well.

2 Likes

Thanks, it seems you were absolutely right with that quick suggestion :).

@SugarAi, great to hear. Antivirus/Antimalware has some strange side effects. Nowadays they tend to be overcautios to prevent encryption malware.

I am still figuring out how to add all TeXLive commands (more than 50) to the whitelist without adding them all single for single with an annoying slow dialog.