halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
466 stars 86 forks source link

Alpine - /bin/java: No such file or directory #181

Open serragnoli opened 2 years ago

serragnoli commented 2 years ago

I have been getting an error on getting JDK installed on Alpine Linux via asdf. Is it a missing dependency issue? If so, is it possible to get it/them installed?

Steps followed to install the JDK

$ docker run -it alpine:3.15.4 ash
$ apk update && apk upgrade
$ apk add --no-cache git curl bash
$ bash
$ git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.10.0
$ asdf --version
bash: asdf: command not found
$ source $HOME/.asdf/asdf.sh
$ asdf --version
v0.10.0-77fd510
$ asdf plugin-add java https://github.com/halcyon/asdf-java.git
$ asdf install java adoptopenjdk-17.0.0+35

$ ls -lah /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/java
-rwxr-xr-x    1 root     root       12.5K Sep 14  2021 /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/java # <<< The location exists

$ /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/java -version
bash: /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/java: No such file or directory # <<< Why does it think it doesn't exist?
paoloambrosio-skyuk commented 2 years ago

I think this issue should be closed as the issue seems to be an with Java on Alpine rather than asdf-java.

I believe that it is caused by Alpine using "musl libc" and instead of "glibc". apk add libc6-compat will fix the "No such file or directory" error whenexecuting the command, but will show a different issue:

# /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/java -version
Error relocating /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/../lib/libjli.so: __strdup: symbol not found
Error relocating /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/../lib/libjli.so: __rawmemchr: symbol not found
pauloreis7 commented 1 year ago

I am using WSL2 with ubuntu and I got the same issue. I really don't know why it thinks dir doesn't exist when I run:

paulo in ~ λ java -version
/home/paulo/.asdf/lib/commands/command-exec.bash: line 28: /home/paulo/.asdf/installs/java/zulu-musl-17.38.21/bin/java: No such file or directory

Env:

OS:
Linux LAPTOP-MFFGV97N 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

SHELL:
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)

ASDF VERSION:
v0.10.2-7e7a1fa

ASDF ENVIRONMENT VARIABLES:
ASDF_DIR=/home/paulo/.asdf

ASDF INSTALLED PLUGINS:
aws-amplify-cli              https://github.com/LozanoMatheus/asdf-aws-amplify-cli.git main 41adc0c
awscli                       https://github.com/MetricMike/asdf-awscli.git main c645552
java                         https://github.com/halcyon/asdf-java.git master 0720a4b
nodejs                       https://github.com/asdf-vm/asdf-nodejs.git master c9e5df4 
ojuliomiguel commented 1 year ago

I think this issue should be closed as the issue seems to be an with Java on Alpine rather than asdf-java.

I believe that it is caused by Alpine using "musl libc" and instead of "glibc". apk add libc6-compat will fix the "No such file or directory" error whenexecuting the command, but will show a different issue:

# /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/java -version
Error relocating /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/../lib/libjli.so: __strdup: symbol not found
Error relocating /root/.asdf/installs/java/adoptopenjdk-17.0.0+35/bin/../lib/libjli.so: __rawmemchr: symbol not found

I'm using ubuntu 22.04 and getting this error :/

andreleao1 commented 1 year ago

I'm using the version zulu-musl-17.42.19 and I'm getting the same error

TheAifam5 commented 11 months ago

Since the data already contains alpine/musl releases of JDKs and the script allows manipulating the grep input: release_data=$(grep "^${ASDF_INSTALL_VERSION} " "${CACHE_DIR}/releases-${OS}-${ARCHITECTURE}.tsv" | tail -n 1) what I did, I set the version to adoptopenjdk-17.0.9+9.*alpine.* to just get the alpine version.

vscode ➜ /workspaces/xyz $ java --version
openjdk 17.0.9 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode, sharing)

on docker with alpine:3.19 with no additional packages (no libc6-compat or anything).

I wish there is a better way like using selectors ":alpine" or by adding "-musl" suffix to the version or even autodetection based on /etc/os-release for now.

dizzib commented 4 months ago

I was also getting the same “No such file or directory” error with openjdk-17, but liberica-jre-musl-17.0.11+12 seems to work without error in Alpine.