Gradle Wrapper throws FileNotFoundException

From time to time, Gradle Wrapper fails with exception:

Exception in thread “main” java.io.FileNotFoundException: /home/teamcity/.gradle/wrapper/dists/gradle-2.14-bin/76oc0mnc3ieqtsukq90mp0rxk/gradle-2.14-bin.zip.lck (No such file or directory)
[01:33:30][Step 1/1] at java.io.RandomAccessFile.open0(Native Method)
[01:33:30][Step 1/1] at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
[01:33:30][Step 1/1] at java.io.RandomAccessFile.(RandomAccessFile.java:243)
[01:33:30][Step 1/1] at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:49)
[01:33:30][Step 1/1] at org.gradle.wrapper.Install.createDist(Install.java:48)
[01:33:30][Step 1/1] at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
[01:33:30][Step 1/1] at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
[01:33:30][Step 1/1] Process exited with code 1

What this bin.zip.lck is for, and what can cause the issue?

Gradle Version: 2.14
Operating System: Ubuntu 14.04

Link to CI build https://teamcity.jetbrains.com/viewLog.html?tab=buildLog&logTab=tree&filter=debug&expand=all&buildId=824481#_focus=49
Project sources: https://github.com/JetBrains/Grammar-Kit

Hi,

thank you for your Bug report.

After looking into this I suppose this happens when the user running Gradle does not have write access to the Gradle home directory (/home/teamcity/.gradle in your case).

Have you been able to fix the problem, yet?

Regards,
Stefan

Hello Stefan,

This problem appears from time to time on TeamCity’s cloud agent. Next time I see the erorr, I will check the permissions and come back with more information.