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

Plugin fails to consider the type of the C library for Linux distributions #5

Open
jbartok opened this issue Nov 28, 2022 · 5 comments

Comments

@jbartok
Copy link
Member

jbartok commented Nov 28, 2022

At the moment the plugin is unable to determine the C library type for which it's supposed to provide JDKs.
This is a problem on Linux distributions because a JDK written for Alpine (ie. musl library) won't work on Ubuntu (i.e. glibc library).
For now all the plugin does is to prioritize glibc over musl, so it will work fine on Ubuntu and similar distributions, but won't work fine on Alpine.
Need to figure out a way to determine the exact library version the current JVM is running on.

@jbartok
Copy link
Member Author

jbartok commented Dec 22, 2022

Maybe can use: https://github.com/lovell/detect-libc

@jbartok jbartok removed their assignment Feb 8, 2023
@cromefire
Copy link

Is there any way to override it manually as a stop gap?

@jbartok
Copy link
Member Author

jbartok commented Jan 15, 2024

Is there any way to override it manually as a stop gap?

Not that I'm aware of. But contributions are welcome.

@karol-burczynski-ck
Copy link

karol-burczynski-ck commented Apr 4, 2024

UPDATE 2024-05-13
Following workaround does not work anymore on Alpine Linux 3.19 due to change in musl package. For 3.18 it's still working.

# New error on Alpie Linux 3.19 with musl@1.2.4_git20230717-r4
> Failed to calculate the value of task ':app:compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching the requirements ({languageVersion=21, vendor=AMAZON, implementation=vendor-specific}) from 'https://api.foojay.io/disco/v3.0/ids/29f9fe87efdd0582e4ce1569fd1b33a9/redirect'.
      > Provisioned toolchain '/root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.3.9.1-linux-x64' could not be probed: Command returned unexpected result code: 6
        Error output:
        Error: dl failure on line 541
        Error: failed /root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.3.9.1-linux-x64/lib/server/libjvm.so, because Error relocating /root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.3.9.1-linux-x64/lib/server/libjvm.so: posix_fallocate64: symbol not found

I'm not C expert so I'm unable to tell what have changed between musl@1.2.4_git20230717-r4 and musl@1.2.4-r2 and why it was introduced but sad fact is that latest available gcompat@1.1.0-r4 is not fully working with it and it's not possible to easily downgrade it 🙁


Original post 2024-04-04

For anyone who have encounter related issue on Alpine Linux distribution and foojay plugin e.g.

> Failed to calculate the value of task ':app:compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching the requirements ({languageVersion=21, vendor=AMAZON, implementation=vendor-specific}) from 'https://api.foojay.io/disco/v3.0/ids/2ff40fc75fd514e8fd248f3d7fca9b58/redirect'.
      > Provisioned toolchain '/root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.2.14.1-linux-x64' could not be probed: A problem occurred starting process 'command '/root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.2.14.1-linux-x64/bin/java''

Official documentation suggest:

As a consequence, using multiple java toolchains is discouraged in environments with the musl library. This is the case in most Alpine distributions — consider using another distribution, like Ubuntu, instead.

If you don't want to switch over to other distribution, one of possible workaround is to install gcompat package offered within official Alpine Linux repository that is providing compatibility layer that works with foojay plugin.

This distribution contains the implementation of gcompat, a library which
provides glibc-compatible APIs for use on musl libc systems.

apk add gcompat

@karol-burczynski-ck
Copy link

UPDATE 2024-05-13 Following workaround does not work anymore on Alpine Linux 3.19 due to change in musl package. For 3.18 it's still working.

# New error on Alpie Linux 3.19 with musl@1.2.4_git20230717-r4
> Failed to calculate the value of task ':app:compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching the requirements ({languageVersion=21, vendor=AMAZON, implementation=vendor-specific}) from 'https://api.foojay.io/disco/v3.0/ids/29f9fe87efdd0582e4ce1569fd1b33a9/redirect'.
      > Provisioned toolchain '/root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.3.9.1-linux-x64' could not be probed: Command returned unexpected result code: 6
        Error output:
        Error: dl failure on line 541
        Error: failed /root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.3.9.1-linux-x64/lib/server/libjvm.so, because Error relocating /root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.3.9.1-linux-x64/lib/server/libjvm.so: posix_fallocate64: symbol not found

I'm not C expert so I'm unable to tell what have changed between musl@1.2.4_git20230717-r4 and musl@1.2.4-r2 and why it was introduced but sad fact is that latest available gcompat@1.1.0-r4 is not fully working with it and it's not possible to easily downgrade it 🙁

Original post 2024-04-04

For anyone who have encounter related issue on Alpine Linux distribution and foojay plugin e.g.

> Failed to calculate the value of task ':app:compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching the requirements ({languageVersion=21, vendor=AMAZON, implementation=vendor-specific}) from 'https://api.foojay.io/disco/v3.0/ids/2ff40fc75fd514e8fd248f3d7fca9b58/redirect'.
      > Provisioned toolchain '/root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.2.14.1-linux-x64' could not be probed: A problem occurred starting process 'command '/root/.gradle/jdks/amazon-corretto-21/amazon-corretto-21.0.2.14.1-linux-x64/bin/java''

Official documentation suggest:

As a consequence, using multiple java toolchains is discouraged in environments with the musl library. This is the case in most Alpine distributions — consider using another distribution, like Ubuntu, instead.

If you don't want to switch over to other distribution, one of possible workaround is to install gcompat package offered within official Alpine Linux repository that is providing compatibility layer that works with foojay plugin.

This distribution contains the implementation of gcompat, a library which
provides glibc-compatible APIs for use on musl libc systems.

apk add gcompat

I have updated my original post since on newer musl version this workaround it's no longer working 😞

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

3 participants