halcyon / asdf-java

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

asdf list-all java errors out for sapmachine.json #93

Closed x80486 closed 4 years ago

x80486 commented 4 years ago

There is something going on with SAP Machine builds (or something like that):

[x80486uplink:~]$ asdf list-all java 
jq: error: Could not open file /tmp/asdf-java.cache/sapmachine.json: No such file or directory
adopt-openjdk-10.0.2+13.1
adopt-openjdk-11+28
adopt-openjdk-11.0.1+13
adopt-openjdk-11.0.2+7
adopt-openjdk-11.0.2+9
adopt-openjdk-11.0.3+7
adopt-openjdk-11.0.4+11
adopt-openjdk-11.0.5+10
adopt-openjdk-11.0.6+10
adopt-openjdk-11.0.7+10
adopt-openjdk-12+33
adopt-openjdk-12.0.1+12
adopt-openjdk-12.0.2+10
adopt-openjdk-13+33
adopt-openjdk-13.0.1+9
adopt-openjdk-13.0.2+8
adopt-openjdk-14+36
adopt-openjdk-14.0.1+7
adopt-openjdk-8u181-b13
adopt-openjdk-8u192-b12
adopt-openjdk-8u202-b08
adopt-openjdk-8u212-b03
adopt-openjdk-8u212-b04
adopt-openjdk-8u222-b10
adopt-openjdk-8u232-b09
adopt-openjdk-8u242-b08
adopt-openjdk-8u252-b09
adopt-openjdk-9+181
adopt-openjdk-9.0.4+11
amazon-corretto-11.0.3.7.1
amazon-corretto-11.0.4.11.1
amazon-corretto-11.0.5.10.1
amazon-corretto-11.0.5.10.2
amazon-corretto-11.0.6.10.1
amazon-corretto-11.0.6.10.1-2
amazon-corretto-11.0.7.10.1
amazon-corretto-8.212.04.2
amazon-corretto-8.232.09.1
amazon-corretto-8.232.09.2
amazon-corretto-8.242.07.1
amazon-corretto-8.242.08.1
amazon-corretto-8.252.09.1
azul-zulu-11.31.11-jdk11.0.3
azul-zulu-11.35.13-jdk11.0.5
azul-zulu-11.35.15-jdk11.0.5
azul-zulu-11.37.17-jdk11.0.6
azul-zulu-11.39.15-jdk11.0.7
azul-zulu-12.2.3-jdk12.0.1
azul-zulu-13.27.9-jdk13
azul-zulu-13.28.11-jdk13.0.1
azul-zulu-13.29.9-jdk13.0.2
azul-zulu-14.27.1-jdk14
azul-zulu-7.29.0.5-jdk7.0.222
azul-zulu-7.34.0.5-jdk7.0.242
azul-zulu-7.36.0.5-jdk7.0.252
azul-zulu-8.42.0.21-jdk8.0.232
azul-zulu-8.42.0.23-jdk8.0.232
azul-zulu-8.44.0.11-jdk8.0.242
azul-zulu-8.44.0.9-jdk8.0.242
azul-zulu-8.46.0.19-jdk8.0.252
azul-zulufx-11.35.15-jdk11.0.5
azul-zulufx-11.37.19-jdk11.0.6
azul-zulufx-8.42.0.23-jdk8.0.232
azul-zulufx-8.44.0.13-jdk8.0.242
azul-zulufx-8.46.0.19-jdk8.0.252
adopt-openjdk-10.0.2+13_openj9-0.9.0
adopt-openjdk-11.0.2+9_openj9-0.12.1
adopt-openjdk-11.0.3+7_openj9-0.14.0
adopt-openjdk-11.0.3+7_openj9-0.14.3
adopt-openjdk-11.0.4+11_openj9-0.15.1
adopt-openjdk-11.0.5+10_openj9-0.17.0
adopt-openjdk-11.0.6+10_openj9-0.18.0
adopt-openjdk-11.0.6+10_openj9-0.18.1
adopt-openjdk-11.0.7+10_openj9-0.20.0
adopt-openjdk-12+33_openj9-0.13.0
adopt-openjdk-12.0.1+12_openj9-0.14.1
adopt-openjdk-12.0.2+10_openj9-0.15.1
adopt-openjdk-13+33_openj9-0.16.0
adopt-openjdk-13.0.1+9_openj9-0.17.0
adopt-openjdk-13.0.2+8_openj9-0.18.0
adopt-openjdk-14+36.1_openj9-0.19.0
adopt-openjdk-14+36_openj9-0.19.0
adopt-openjdk-14.0.1+7_openj9-0.20.0
adopt-openjdk-8u162-b12_openj9-0.8.0
adopt-openjdk-8u181-b13_openj9-0.9.0
adopt-openjdk-8u192-b12_openj9-0.11.0
adopt-openjdk-8u202-b08_openj9-0.12.1
adopt-openjdk-8u212-b03_openj9-0.14.0
adopt-openjdk-8u212-b04_openj9-0.14.2
adopt-openjdk-8u222-b10_openj9-0.15.1
adopt-openjdk-8u232-b09_openj9-0.17.0
adopt-openjdk-8u242-b08_openj9-0.18.1
adopt-openjdk-8u252-b09_openj9-0.20.0
adopt-openjdk-9.0.4+12_openj9-0.9.0
adopt-openjdk-11.0.2+9_openj9-0.12.1_large-heap
adopt-openjdk-11.0.3+7_openj9-0.14.0_large-heap
adopt-openjdk-11.0.3+7_openj9-0.14.3_large-heap
adopt-openjdk-11.0.4+11_openj9-0.15.1_large-heap
adopt-openjdk-11.0.5+10_openj9-0.17.0_large-heap
adopt-openjdk-11.0.6+10_openj9-0.18.0_large-heap
adopt-openjdk-11.0.6+10_openj9-0.18.1_large-heap
adopt-openjdk-11.0.7+10_openj9-0.20.0_large-heap
adopt-openjdk-12+33_openj9-0.13.0_large-heap
adopt-openjdk-12.0.1+12_openj9-0.14.1_large-heap
adopt-openjdk-12.0.2+10_openj9-0.15.1_large-heap
adopt-openjdk-13+33_openj9-0.16.0_large-heap
adopt-openjdk-13.0.1+9_openj9-0.17.0_large-heap
adopt-openjdk-13.0.2+8_openj9-0.18.0_large-heap
adopt-openjdk-14+36.1_openj9-0.19.0_large-heap
adopt-openjdk-14+36_openj9-0.19.0_large-heap
adopt-openjdk-14.0.1+7_openj9-0.20.0_large-heap
adopt-openjdk-8u192-b12_openj9-0.11.0_large-heap
adopt-openjdk-8u202-b08_openj9-0.12.1_large-heap
adopt-openjdk-8u212-b03_openj9-0.14.0_large-heap
adopt-openjdk-8u212-b04_openj9-0.14.2_large-heap
adopt-openjdk-8u222-b10_openj9-0.15.1_large-heap
adopt-openjdk-8u232-b09_openj9-0.17.0_large-heap
adopt-openjdk-8u242-b08_openj9-0.18.1_large-heap
adopt-openjdk-8u252-b09_openj9-0.20.0_large-heap

It happens even if I remove the /tmp/asdf-java.cache/ before executing that command. I'm using ASDF version v0.7.8-4a3e3d6 under Arch Linux with GNU bash, version 5.0.16(1)-release.

Also, isn't weird that the list is split for adopt-openjdk?

ethorne commented 4 years ago

I am seeing this behavior as well. I changed my ~/.tool-versions file from java adoptopenjdk-8.212 to java adopt-openjdk-8u212-b03 and that seemed to solve this issue.

Retia-Adolf commented 4 years ago

It seems that it didn't download sapmachine.json,so I got in ~/.asdf/plugins/java/bin/list-all to have a look.

Saw line 65, 80, 81, it needs to download https://api.github.com/repos/SAP/SapMachine/releases, and process json it downloaded. But it seems that line 80 not executed successfully:

curl "${github_curl_opts[@]}" "${url}" -o "${CACHE_DIR}/sapmachine.json" > /dev/null 2>&1

Cause

may be caused of

local github_curl_opts=("${CURL_OPTS[@]}" '-H' "Authorization: token $GITHUB_API_TOKEN")

I haven't set the GITHUB_API_TOKEN variable to let it work at all.

Solution

To get a token (don't know how) or it seems not needed in a rarely usage case, so:

# edit it out:
local github_curl_opts=("${CURL_OPTS[@]}" '-H' "Authorization: token $GITHUB_API_TOKEN")
# to:
local github_curl_opts=("${CURL_OPTS[@]}")

or workaround for myself:

# First, manually save `https://api.github.com/repos/SAP/SapMachine/releases` from Browser to `/tmp/asdf-java.cache/sapmachine.json`
# enter bash
source ~/.asdf/plugins/java/bin/list-all
# copy-paste code segment at line 81-100 in the file, to finish its json processing:
jq '[.[]
     | select(.prerelease == false and .draft == false)
     | {
         release_name: .name,
         binaries: [
         .assets[]
         | select(.content_type == "application/x-tar")
         | select(.name | startswith("sapmachine-jdk"))
         | select(.name | endswith("linux-x64_bin.tar.gz") or endswith("osx-x64_bin.tar.gz"))
         | {
              package: {
                link: .browser_download_url,
                checksum_link: (.browser_download_url | sub("tar\\.gz$"; "sha256.txt"))
              },
              os: (if .name | endswith("osx-x64_bin.tar.gz") then "mac" else "linux" end),
              architecture: "x64",
              jvm_impl: "hotspot",
              heap_size: "normal"
           }]}]' "${CACHE_DIR}/sapmachine.json" > "${CACHE_DIR}/sapmachine.temp"
mv "${CACHE_DIR}"/sapmachine.temp "${CACHE_DIR}"/sapmachine.json
joschi commented 4 years ago

This should be solved by merging #87:

# asdf list-all java | grep ^sapm
sapmachine-11.0.6
sapmachine-11.0.6.0.1
sapmachine-11.0.7
sapmachine-13.0.2
sapmachine-14
sapmachine-14.0.1
x80486 commented 4 years ago

Fixed via #87