reuse-tool
reuse-tool copied to clipboard
Race condition in `reuse lint` causes unnecessary failures
reuse lint appears to collect a list of paths to check and then iterate over the collected paths and generate a report for them. If a file is created in time for it to be collected into the list and deleted before its report gets generated, reuse lint fails. I believe the root cause is the exception raised here:
https://github.com/fsfe/reuse-tool/blob/a7896a5be6347cc917abb7eb3afd7fffbcedb99b/src/reuse/report.py#L730
I think this situation should not cause reuse lint to fail but rather be handled gracefully by simply ignoring files that no longer exist.
Reuse is about ensuring that all files have proper licensing and copyright information. Having files appear/disappear while reuse is running seems to undermine that goal. Personally, I'd really not want reuse to try to be clever in such cases, and I want it to fail.
Hmm, my use case is that I'd like to run reuse lint in CI for my projects, which also runs a bunch of other things, all of which run concurrently. When I noticed this issue, the specific files I was getting this error with were intermediate files generated by a compiler.
Also, if files are created after reuse lint collects its path list but before it generates reports for them, reuse lint will currently silently ignore them. I'm not sure if that would really be possible to fix.
I'm not sure if that would really be possible to fix.
Run reuse before anything else. There should be no need to do it concurrently, as reuse does not take a long time to finish.
Alternatively - how about list the (I guess) files generated by other parts of the build system into .gitignore?
Alternatively - how about list the (I guess) files generated by other parts of the build system into
.gitignore?
Hmm, but they are...
Ah, I think I see the problem: the particular situation in which this arose for me was testing generated projects from a template, and the generation does not do git init. So, a .gitignore exists, but there is no .git directory. I guess that must be causing reuse to not respect the .gitignore for some reason.