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?

superM
  • 8,605
  • 8
  • 42
  • 51
  • Funny, I don't have this issue at all on ubuntu and the latest gradle version. Which gradle are you using? – frhd Aug 31 '15 at 14:21
  • @frhd it's Gradle 2.0 – superM Aug 31 '15 at 14:23
  • 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. – frhd Aug 31 '15 at 14:26
  • Can you delete the `.lock` file and try again running & cancelling the build? Maybe it was just a hiccup. – frhd Aug 31 '15 at 14:27
  • 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. – superM Aug 31 '15 at 14:49
  • Have you tried using the latest gradle version? 2.0 is pretty dated. – frhd Sep 01 '15 at 08:45

2 Answers2

12

Clear with a command:

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

MAC

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

LINUX

find ~/.gradle/ -name "*.lock" | xargs rm
Saket
  • 2,945
  • 1
  • 29
  • 31
leandro.dev
  • 345
  • 2
  • 8
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.

weston
  • 54,145
  • 21
  • 145
  • 203
frhd
  • 9,396
  • 5
  • 24
  • 41