Skip to content

Java feature: installMaven fails with "var/platform: No such file or directory" when version="none" (regression from #1714) #1719

Description

@Hamamatsu-Hironori

Description

When version is set to "none" and installMaven is true with a plain numeric mavenVersion (e.g. 3.8.8), the Java feature fails with:

cat: /usr/local/sdkman/var/platform: No such file or directory
ERROR: Feature "Java (via SDKMAN!)" (ghcr.io/devcontainers/features/java) failed to install!

Reproduction

"features": {
    "ghcr.io/devcontainers/features/java:1": {
        "version": "none",
        "installMaven": "true",
        "mavenVersion": "3.8.8",
        "installGradle": "false"
    }
}

Feature install log:

===========================================================================
Feature       : Java (via SDKMAN!)
Description   : Installs Java, SDKMAN! (if not installed), and needed dependencies.
Id            : ghcr.io/devcontainers/features/java
Version       : 1.8.2
Documentation : https://github.com/devcontainers/features/tree/main/src/java
Options       :
    VERSION="none"
    ADDITIONALVERSIONS=""
    JDKDISTRO="ms"
    INSTALLGRADLE="false"
    GRADLEVERSION="latest"
    INSTALLMAVEN="true"
    MAVENVERSION="3.8.8"
    INSTALLANT="false"
    ANTVERSION="latest"
    INSTALLGROOVY="false"
    GROOVYVERSION="latest"
===========================================================================
cat: /usr/local/sdkman/var/platform: No such file or directory
ERROR: Feature "Java (via SDKMAN!)" (ghcr.io/devcontainers/features/java) failed to install! Look at the documentation at https://github.com/devcontainers/features/tree/main/src/java for help troubleshooting this error.

Root cause

This looks like a regression introduced by #1714 ("Fix java version matching", merged 2026-08-26).

That PR added this line to find_version_list() in src/java/install.sh:

platform="$(cat ${SDKMAN_DIR}/var/platform)"

sdk_install() only skips find_version_list() when the requested version already matches the JDK-style identifier suffix (.*-[a-z]+$, e.g. 21.0.12+1-ms). A plain numeric Maven/Gradle/Ant version such as 3.8.8 does not match that pattern, so it falls through into find_version_list(), which now unconditionally does cat "${SDKMAN_DIR}/var/platform".

var/platform is only written by SDKMAN's own installer (get.sdkman.io), which the feature runs inside:

if [ ! -d "${SDKMAN_DIR}" ]; then
    ...
    run_with_retries 5 10 "Installing SDKMAN" install_sdkman_cli
    ...
fi

With version: "none", sdk_install java none returns immediately without ever installing a JDK (src/java/install.sh line ~271). If SDKMAN_DIR already exists at this point (e.g. carried over from a cached image layer, base image, or a previous feature run) but wasn't populated by install_sdkman_cli in this run, var/platform never gets created, and the subsequent sdk_install maven ... call blows up trying to cat a file that doesn't exist.

Before #1714, find_version_list() resolved available versions via sdk list <type> | grep ... instead of hitting the SDKMAN API directly, so it didn't depend on var/platform being present.

Suggested fix

  • Don't assume var/platform exists in find_version_list(); either derive the platform independently (e.g. via uname), or guard the cat with a check/fallback (re-run the platform detection, or source sdkman-init.sh first so SDKMAN itself materializes it).
  • Alternatively, ensure SDKMAN bootstrap (install_sdkman_cli) always runs when SDKMAN_DIR exists but is not fully initialized, rather than only guarding on directory existence.

Feature version

ghcr.io/devcontainers/features/java:1, feature script version 1.8.2 (post-#1714).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions