./gradlew build failing with lock error

Been working on this from yesterday
I have also tried googling but could not solve it.

This is the error.

Exception in thread “main” java.lang.RuntimeException: Could not create parent directory for lock file /home/crio-user/
.gradle/wrapper/dists/gradle-5.2.1-bin/9lc4nzslqh3ep7ml2tp68fk8s/gradle-5.2.1-bin.zip.lck
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:43)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
No stash entries found.
error: failed to push some refs to ‘git@gitlab.crio.do:COHORT_ME_QMONEY_ENROLL_CRIO_LAUNCH_2020/swapnil-ace9719-ME_QMONEY.git’

Please help

try this https://github.com/redhat-developer/vscode-java/issues/781#issuecomment-460590211

Actually my file has correct values which are specified in the post.
Anyway i removed it but still did not work without sudo.
same error.

Did you use sudo by mistake anywhere?

Try deleting everything inside this directory - home/crio-user/ .gradle/wrapper/dists/

Also there are chances that some ghadle command is running in the background d, which is still holding locks.
Try doing \gradlew --stop to stop all running gradle commands.

Yes i did,one of friends had similar issue so he used sudo too but did not face any issues

no gradle deamons are running

@anand-crio deleting contents of dist does directory leads to following error

Downloading https://services.gradle.org/distributions/gradle-5.2.1-bin.zip

Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not create service of type ScriptPluginFactory using BuildScopeServices.createScriptPluginFactory().

Could not create service of type FileHasher using BuildSessionScopeServices.createFileSnapshotter().

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 5s

So, if you used sudo, then there are some files created as root, which you don’t have permissions to delete.

Try a gradle clean before you build.

@anand-crio clean build failing with same error

Can you tell which java version you are using?
Run
java --version
./gradlew --version

And let me know the output.

@anand-crio
java -version

openjdk version “1.8.0_242”
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

./gradlew --version

Welcome to Gradle 5.2.1!

Here are the highlights of this release:

  • Define sets of dependencies that work together with Java Platform plugin
  • New C++ plugins with dependency management built-in
  • New C++ project types for gradle init
  • Service injection into plugins and project extensions

For more details see https://docs.gradle.org/5.2.1/release-notes.html


Gradle 5.2.1

Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183

Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant™ version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_242 (Private Build 25.242-b08)
OS: Linux 4.14.146-119.123.amzn2.x86_64 amd64

@anand-crio
Another useful piece of information maybe

Caused by: java.io.FileNotFoundException: /home/crio-user/workspace/swapnil-ace9719-ME_QMONEY/.gradle/5.2.1/fileHashes/fileHashes.lock (Permission denied)

Oh, cool…

sudo rm -rf /home/crio-user/workspace/swapnil-ace9719-ME_QMONEY/.gradle

This should solve the issue. Take the backup of the code before you delete this dir. Any mistake can accidently wipe out all of your code.

@anand-crio
Actually i just changed file pemissions for all files recursively to 770 and git push worked
And i even passed all cases.

Thanks for bearing with me

1 Like