Gradle .lock files not removed when stopping build manually
Asked Answered
B

2

9

When running gradle build from command line and manually terminating with Ctrl+Z, the .lock files, generated by gradle aren't removed. During the next build, I get a build failure with the following message:

.....
> Timeout waiting to lock artifact cache (...). It is currently in use by another Gradle instance.
Owner PID: ...
.....

When I kill the process and run build again, the message doesn't change. Even the process ID remains the same.

Is there a recommended way of stopping a gradle task from command line? Otherwise, is it possible to clean the hanging .lock files?

Barrens answered 31/8, 2015 at 10:24 Comment(6)
Funny, I don't have this issue at all on ubuntu and the latest gradle version. Which gradle are you using?Erector
@Erector it's Gradle 2.0Barrens
1. I always CTRL+C the build and there is no lock file. I'm not aware of a different way of cancelling a command line process :) 2. You can manually delete the .lock file. Of course, that leaves the question why you have the file in the first place.Erector
Can you delete the .lock file and try again running & cancelling the build? Maybe it was just a hiccup.Erector
The build isn't always successful after deleting the .lock file. Though when closing the terminal the issue resolves. But this still doesn't answer the question of terminating the build correctly.Barrens
Have you tried using the latest gradle version? 2.0 is pretty dated.Erector
F
14

Clear with a command:

find . -name "*.lock" | xargs rm

MAC

find ~/.gradle/ -name "*.lock" | xargs rm

LINUX

find ~/.gradle/ -name "*.lock" | xargs rm
Finkle answered 6/7, 2021 at 11:24 Comment(1)
Ran into a build issue after deleting gradle cache manually. I tried lots of things but this was the one that seemed to work.Neediness
E
4

1. When running your non-daemon build in one terminal, you can stop it in another terminal simply with

gradle --stop

2. The .lock file should be cleaned up whenever a non-daemon build is terminated correctly within the same context. If not, you can delete it manually.

I recommend using the latest gradle version.

Erector answered 31/8, 2015 at 15:0 Comment(4)
Tried gradle -stop, but it's saying that no Gradle deamons are running.Barrens
1. Have you used gradle -stop with the same build file? 2. Was the build running at that time?Erector
The build was running, and I ran the command from the same directory in the second terminal.Barrens
find . -name ".lock" | xargs rmLear

© 2022 - 2024 — McMap. All rights reserved.