Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graal images failed to load native library 'libnative-platform.so' for Linux amd64. #255

Closed
XhstormR opened this issue Aug 16, 2023 · 5 comments

Comments

@XhstormR
Copy link

When I use the default root user, I can run gradle normally, but when I switch to the gradle user, the program fails to run.

You can see that the permissions of the /home/gradle/.gradle folder belong to root, and the gradle user has no permissions.

 ❯ docker run -u 1000 --rm -it gradle:graal bash -c  'id && pwd && ls -la && gradle --version'                                                                   (base)
uid=1000(gradle) gid=1000(gradle) groups=1000(gradle)
/home/gradle
total 12
drwxr-x--- 1 gradle gradle   54 Aug 15 23:22 .
drwxr-xr-x 1 root   root     12 Aug 15 23:20 ..
-rw-r--r-- 1 gradle gradle  220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 gradle gradle 3771 Jan  6  2022 .bashrc
drwxr-xr-x 1 root   root      0 Aug 15 23:20 .gradle
-rw-r--r-- 1 gradle gradle  807 Jan  6  2022 .profile

FAILURE: Build failed with an exception.

* What went wrong:
Gradle could not start your build.
> Could not initialize native services.
   > Failed to load native library 'libnative-platform.so' for Linux amd64.

* 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.

The default latest image works fine.

 ❯ docker run -u 1000 --rm -it gradle:latest bash -c  'id && pwd && ls -la && gradle --version'                                                                   (base)
uid=1000(gradle) gid=1000(gradle) groups=1000(gradle)
/home/gradle
total 12
drwxr-x--- 1 gradle gradle    0 Jul 25 23:50 .
drwxr-xr-x 1 root   root     12 Jul 25 23:50 ..
-rw-r--r-- 1 gradle gradle  220 Jan  6  2022 .bash_logout
-rw-r--r-- 1 gradle gradle 3771 Jan  6  2022 .bashrc
drwxr-xr-x 1 gradle gradle    0 Jul 25 23:50 .gradle
-rw-r--r-- 1 gradle gradle  807 Jan  6  2022 .profile

Welcome to Gradle 8.2.1!

Here are the highlights of this release:
 - Kotlin DSL: new reference documentation, assignment syntax by default
 - Kotlin DSL is now the default with Gradle init
 - Improved suggestions to resolve errors in console output
 - Reduced sync memory consumption

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


------------------------------------------------------------
Gradle 8.2.1
------------------------------------------------------------

Build time:   2023-07-10 12:12:35 UTC
Revision:     a38ec64d3c4612da9083cc506a1ccb212afeecaa

Kotlin:       1.8.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.8 (Eclipse Adoptium 17.0.8+7)
OS:           Linux 6.4.8-orbstack-00059-g106c60a3471f amd64
@keeganwitt
Copy link
Owner

Yea, I had this problem during testing, but I thought I fixed it.

What's strange is when I build the image locally, it works, but using the image that the Docker Library Jenkins built, it doesn't 🤔

@keeganwitt
Copy link
Owner

Ah, they're different contents.

$ docker run --rm -u gradle myLocalGradleImage ls -la .gradle      
total 8
drwxr-xr-x 2 root   root   4096 Aug 15 23:20 .
drwxr-x--- 1 gradle gradle 4096 Aug 15 23:22 ..

$ docker run --rm -u gradle gradle:17-graal ls -la .gradle  
total 20
drwxr-xr-x 4 gradle gradle 4096 Aug 16 14:04 .
drwxr-x--- 1 gradle gradle 4096 Aug 16 13:47 ..
drwxr-xr-x 4 gradle gradle 4096 Aug 16 14:04 native

and that directory is a volume, that's why.

keeganwitt added a commit that referenced this issue Aug 16, 2023
Ensure directories in .gradle are created by gradle user (closes #255)
@keeganwitt
Copy link
Owner

Official images PR: docker-library/official-images#15214

@XhstormR
Copy link
Author

XhstormR commented Aug 17, 2023

Weird, still get this issues after pull latest graal images.

 ❯ docker images
REPOSITORY                            TAG       IMAGE ID       CREATED        SIZE
gradle                                graal     e5e4eed24da7   12 hours ago   1.14GB

@keeganwitt
Copy link
Owner

keeganwitt commented Aug 17, 2023

Weird, still get this issues after pull latest graal images.

 ❯ docker images
REPOSITORY                            TAG       IMAGE ID       CREATED        SIZE
gradle                                graal     e5e4eed24da7   12 hours ago   1.14GB

Maybe make sure you're not using a cached image? docker run --rm gradle@sha256:48d1da617a3647cf58dc7e9d2e8bacf8815fac838133680d3014dd01f2696671 gradle --version is what I got from docker pull gradle:graal. https://hub.docker.com/layers/library/gradle/graal/images/sha256-333cbc28fc9ad3413ebb120e04124b533cab8175af643ede3c83614f7d6023d6?context=explore is the sha Docker Hub shows is the latest (docker run --rm gradle@sha256:333cbc28fc9ad3413ebb120e04124b533cab8175af643ede3c83614f7d6023d6 gradle --version). They both work for me.

My tests were done with amd64 images. Docker version 24.0.5 on Docker Desktop 4.22.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants