Here's an unfortunate scenario that is very easy to fall into:
- In your editor you have opened one or more files from
~/.cargo/registry/src, perhaps by navigating to source code in one of your dependencies.
- You make some broad changes in your editor (possibly with search and replace), and inadvertently change one of these external source files.
- You end up reverting your local changes with
git reset --hard.
- Unbeknownst to you, that dependency is still modified, and fails whenever you try to build.
cargo cleandoes not fix it.
It would be helpful if Cargo could somehow detect or prevent this problem. Some ideas, with the most desirable first.
- Cargo always does a hash compare of dependency sources before building.
- When downloading sources, the files are made read-only.
cargo cleanreverts any changes in dependency source code.