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
Gradle can’t delete build folders #29011
Comments
We appreciate the effort, but we must ask for more information so that we can triage it. We do not see an immediate root cause, and we need a minimal reproducible example for the triage. If we have a reproducer, we may be able also to suggest workarounds or ways to avoid the problem. The ideal way to provide a reproducer is to leverage our reproducer template. You can also use Gradle Project Replicator to reproduce the structure of your project. This issue will be closed after 7 days unless you provide more information. Please also clarify why you marked this issue as a regression. Which version of Gradle works for you? |
Thank you for your help! I marked this issue as a regression by mistake. Here is what I included in my build.gradle.kts file:
|
I succeded at applying the plugin. Although it was still a bit strange, I had to add
I also noticed that this "Unable to delete directory" error appears after I change some code in buildSrc. Usually gradle can't delete build folder of "TelegramLib" after the change. The json file: |
@pisfer can you provide the reproducer project, please? Leveraging our reproducer template would be the best option. Do you have some insights on what process prevents Gradle from deleting a file? |
Here is a link for the reproducer project: https://github.com/pisfer/gradle-issue-29011-reproducer And I tried to check which process holds a lock on those files that gradle can't delete, I did not find any locks. Also I noticed that a problem disappeared when I removed: |
I found the problem. It was Google Drive for Desktop that locked those files. Also, Is it possible to tell Gradle not to recompile the whole project if the buildSrc source code was changed? |
Okay, so the problem was caused by the environment. Closing the issue since it's not something that should be fixed in Gradle.
You can refactor your buildSrc login into a plugin and enable the configuration cache. For more details, refer to this doc |
Current Behavior
I have this problem with my Kotlin project. Gradle sometimes gives me an error when trying to build the project. It says it can’t delete some build folders. I can delete them manually, I also tried to use gradlew --stop command and TASKKILL /F /IM java.exe however none of them did anything. The error persists until I manually delete those folders. Also in my project, I have 1 additional module and a buildSrc module for the Gradle plugin (an error was present before this plugin). I have this error in the build folders of all 3 modules randomly.
Expected Behavior
No errors
Context (optional)
Now I have to delete build folders every time I get the error.
Steps to Reproduce
The structure of my project:
I have 3 modules: main one, buildSrc, and TelegramLib. The error was first seen when I included TelegramLib. Now the problem usually starts in the build folder of buildSrc. Firstly I see the error about buildSrc then I delete the folder, then I see a mistake with TelegramLib where I also need to delete a folder, and finally, the main build folder also needs to be deleted manually. I have not noticed a pattern, so it seems to be random when It gives an error and when it does not.
Here is my gradle.kts file for buildSrc:
gradle.kts file for TelegramLib:
gradle.kts file for Main:
Gradle version
Gradle 8.7
Gradle version that used to work
Build scan URL (optional)
https://scans.gradle.com/s/flhksq3rwyziw
Your Environment (optional)
Kotlin: 1.9.22
OS: Windows 11 10.0 amd64
The text was updated successfully, but these errors were encountered: