-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ninja -t cleandead should consider not failing on failure to remove #1886
Comments
This comment was marked as abuse.
This comment was marked as abuse.
The purpose (AFAIK) is to help remove files which used to be part of the build, but are no longer in it (e.g., you've removed a source file, so its object file is now no longer needed). It's a utility tool. If you clean the vacuum the deps log and then do cleandead, it will leave files behind since ninja has removed its knowledge of them. It's not a perfect tool, but an assistant. If it gets in the way like this (which is obviously "something weird going on"), just ignoring the issue (or noting it in output with |
This comment was marked as abuse.
This comment was marked as abuse.
I am the poster of the problem at cmake-discourse. For this simple case it would be sufficient if ninja tries harder to delete the file by trying to remove the read only permission (similar like the -f option of the rm shell command). If this also failed, this might be an error. CMake seems to call ninja -t cleandead automatically after generating the ninja build scripts (which would do there job perfectly) but fails, cause the ninja call failed. Think this call of cmake is perfectly right, cause it must be done after the new build scripts are created, but before the next build. |
What do you mean by that?
Hm ... not sure if this should be the default behavior though. Why not remove the read-only permission when copying the files to the build directory? |
Sorry, edited the sentence and never went back to proofread. When something like
That's also a possibility. I think new enough CMake has Not sure about other generators, but CMake might be able to avoid this pretty easily at least. |
@jhasse: @mathstuf
|
I've just tried: cleandead has no problem removing files without write permissions on my machine. Can you put together a minimal reproducible example? |
@jhasse: Have you tried on Windows? I remember that the problem occurred on windows platform (in a msys shell). Not sure, if there was a failure on linux. Will generate a small example this week. |
No, it was on Linux. |
On Windows, read-only files sometimes need the read-only permission to be removed before the files themselves can be removed. One might also be able to reproduce this on Linux using files in a read-only directory. |
Fixes main complaint of ninja-build#1886.
Feel free to re-open, if you think the fix is not enough. |
Since commit 2d7f7e5 (Delete read-only files on Windows, too, 2020-12-07) we use `DeleteFile` without checking if it failed due to a path missing. Fix the `GetFileAttributes` logic to check for multiple variants of "file not found" as we do in `StatSingleFile`. Then fall back to the original `remove()` logic that already checks for `ENOENT` on failure. Issue: ninja-build#1886
…Windows Revise the logic from commit 2d7f7e5 (Delete read-only files on Windows, too, 2020-12-07) to check if `DeleteFile` failed due to the file already missing. Issue: ninja-build#1886
…Windows Revise the logic from commit 2d7f7e5 (Delete read-only files on Windows, too, 2020-12-07) to check if `DeleteFile` failed due to the file already missing. Issue: ninja-build#1886
…Windows Revise the logic from commit 2d7f7e5 (Delete read-only files on Windows, too, 2020-12-07) to check if `GetFileAttributes` or `DeleteFile` failed due either variant of the file/path-not-found error. Issue: ninja-build#1886
Fixes main complaint of ninja-build#1886.
…Windows Revise the logic from commit 2d7f7e5 (Delete read-only files on Windows, too, 2020-12-07) to check if `GetFileAttributes` or `DeleteFile` failed due either variant of the file/path-not-found error. Issue: ninja-build#1886
The cleandead tool is an assistance, and as such should not trigger failures for "unimportant" problems. One of which is failing to delete one of these files. This was reported to CMake's Discourse but belongs here.
The text was updated successfully, but these errors were encountered: