the-lean-crate / cargo-diet

A cargo-companion to become a 'lean crate' (a member of The Lean Crate Initiative)
https://github.com/the-lean-crate/criner
MIT License
154 stars 3 forks source link

Error after deleting files #7

Closed Anonyfox closed 3 years ago

Anonyfox commented 3 years ago

When I delete a folder with code from a crate in my workspace, cargo diet dies with the error

Error: Could not open "src/workspace/constructor.rs" for reading file meta-data, where workspace is the folder containing some code. If it exists (even when the files contained are empty), it works. If I delete any file (or even the whole folder), I get the error above.

Byron commented 3 years ago

Thanks for reporting! This is interesting as it seems pretty clear where this issue stems from:

https://github.com/the-lean-crate/cargo-diet/blob/abca3ea180ca92ceb5662fa454fcaaf4527db542/src/lib.rs#L232-L252

cargo package is executed to get a list of all paths that it would want to include in the package. This is later used to build a tar archive. For some reason cargo package lists paths that are not present on disk.

The fix would be trivial - ignore non-existing files - but I wonder what you think about this before implementing it.

Anonyfox commented 3 years ago

In my case prio#1 would be that the tool does not die because of this, since I execute it in a loop over all crates within my workspace during CI. Of course it would be helpful if cargo package itself does not return such false positives, but in the short term I'd gladly take the tradeoff that ignores things even if this means not-as-optimal shrinking. Thoughts?

Byron commented 3 years ago

Please let me know if v1.2.1 works for you.

Anonyfox commented 3 years ago

Worked this night without issues, thank you!