Yesterday I was perplexed when my build started breaking, because it couldn't build one of my dependencies. I eventually traced the problem to the fact that the files in my ~/.carg/reigistry/src
directory had been modified, and were now not compiling. I fixed it by deleting those files and letting cargo redownload them.
I'm pretty sure what happened is this:
- I opened my project in VSCode
- I used the 'Go To Definition' action on one of the dependencies definitions
- VSCode opened the source file of my dependency in the
~/.cargo/registry/src
tree - I accidentally hit some keystrokes while that window was active
- VSCode auto-saves the file to
~/.cargo/registry/src
It is nice, sometimes, to be able to see the exact code of my dependencies. But I can't imagine there being any good reason to edit those files directly--at least, not without specific intent. But try as I might, I can't find any way to prevent VSCode from opening those files as editable by default. (I assume, as well, that trying to make my entire cargo registry read-only would cause other problems).
Is there something I'm missing? Does anyone have a way to configure VSCode to prevent this mistake from happening? Or do you just have to be careful?