4

I am trying to create a jenkins slave for building gradle lambda projects. Jenkins slave is throwing the below error while building the project.

Exception in thread "main" java.lang.RuntimeException: Could not create parent directory for lock file /gradle/wrapper/dists/gradle-4.2.1-bin/dajvke9o8kmaxbu0kc5gcgeju/gradle-4.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)
/home/jenkins/workspace/ddoa-subprod/lf-security-gateway2/lf-security-gateway2

FAILURE: Build failed with an exception.

* What went wrong:
Failed to load native library 'libnative-platform.so' for Linux amd64.

Please help me in understanding the issue and let me know how to fix the same.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Anil Bhaskaran
  • 495
  • 1
  • 8
  • 23

3 Answers3

3

To fix this error: What went wrong: Failed to load native library 'libnative-platform.so' for Linux amd64. do the following:

  1. Check if your Gradle cache (**~user/.gradle/**native folder exist at all or not).
  2. Check if your Gradle cache (~user/.gradle/native folder exist and the file in question i.e. libnative-platform.so exists in that directory or not).
  3. Check if the above folder ~user/.gradle or ~/.gradle/native or file: ~/.gradle/native/libnative-platform.so has valid permissions (should not be read-only. Running chmod -R 755 ~/.gradle is enough).

IF you don't see native folder at all or if your native folder seems corrupted, run your Gradle task ex: gradle clean build using -g or --gradle-user-home option and pass it's value.

Ex: If I ran mkdir /tmp/newG_H_Folder; gradle clean build -g /tmp/newG_H_Folder, you'll see Gradle will populate all the required folder/files (that it needs to run even before running any task or any option) are now in this new Gradle Home folder (i.e. /tmp/newG_H_Folder/.gradle directory).

From this folder, you can copy - just the native folder to your user's ~/.gradle folder (take backup of existing native folder in ~/.gradle first if you want to) if it already exists -or copy the whole .gradle folder to your ~ (home directory).

Then rerun your Gradle task and it won't error out anymore.

Gradle docs says: https://docs.gradle.org/current/userguide/command_line_interface.html

-g, --gradle-user-home Specifies the Gradle user home directory. The default is the .gradle directory in the user’s home directory.

Note: using gradle <sometask> -g <a_dynamic_folder_ex_jenkins_workspace> will always work as Gradle will create fresh .gradle cache in that -g defined folder, but doing this, it'll not reap the true benefit of Gradle's cache concept.

AKS
  • 16,482
  • 43
  • 166
  • 258
1

If you are using a version 3.4 if Gradle, then it could possibly be this issue.

To fix it, you can try to update your Gradle distribution to version 3.5 or higher, where this issue was solved.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
0

I ran the command as sudo and it went through fine

Anil Bhaskaran
  • 495
  • 1
  • 8
  • 23