Skip to content

Fix Java feature installMaven failure when version="none" (missing var/platform) - #1721

Merged
Abdurrahmaan Iqbal (abdurriq) merged 7 commits into
mainfrom
copilot/fix-install-maven-error
Sep 2, 2026
Merged

Fix Java feature installMaven failure when version="none" (missing var/platform)#1721
Abdurrahmaan Iqbal (abdurriq) merged 7 commits into
mainfrom
copilot/fix-install-maven-error

Conversation

Copilot AI commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

When version: "none" is combined with installMaven: true and a plain numeric mavenVersion (e.g. 3.8.8), the feature aborts with:

cat: /usr/local/sdkman/var/platform: No such file or directory

This is a regression from #1714, which made find_version_list() read ${SDKMAN_DIR}/var/platform unconditionally. That file is only written by SDKMAN's own bootstrap. With version: "none", the JDK install returns early without bootstrapping SDKMAN, so when SDKMAN_DIR already exists (cached layer/base image) the file is absent and the subsequent Maven install fails.

Changes

  • src/java/install.sh: Added a get_sdkman_platform() helper that reads var/platform when present, and otherwise derives the platform identifier from uname (mirroring get.sdkman.io's infer_platform). Replaced the unconditional cat in find_version_list() with a call to this helper.
get_sdkman_platform() {
    if [ -f "${SDKMAN_DIR}/var/platform" ]; then
        cat "${SDKMAN_DIR}/var/platform"
        return
    fi
    # fall back to uname-based detection: LinuxX64, LinuxARM64, DarwinARM64, ...
}
  • test/java: Added the install_maven_specific_version_no_java scenario (version: "none", installMaven: true, mavenVersion: "3.8.8", installGradle: false) and a test asserting Maven 3.8.8 installs successfully.

Copilot AI and others added 2 commits September 1, 2026 13:01
Co-authored-by: Kaniska244 <186041440+Kaniska244@users.noreply.github.com>
Co-authored-by: Kaniska244 <186041440+Kaniska244@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix installMaven failure with version="none" Fix Java feature installMaven failure when version="none" (missing var/platform) Sep 1, 2026
@Kaniska244

Copy link
Copy Markdown
Contributor

Copilot Change the configuration of the newly added test by replacing the base image with mcr.microsoft.com/devcontainers/java:1-8-bullseye.

Co-authored-by: Kaniska244 <186041440+Kaniska244@users.noreply.github.com>

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Copilot Change the configuration of the newly added test by replacing the base image with mcr.microsoft.com/devcontainers/java:1-8-bullseye.

Updated the install_maven_specific_version_no_java scenario to use mcr.microsoft.com/devcontainers/java:1-8-bullseye as the base image.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new uname-based platform detection misses common Linux architecture aliases (e.g. i386/amd64), which can cause incorrect SDKMAN platform selection on some systems.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Fixes a regression in the Java feature’s SDKMAN version resolution path when version: "none" is used, ensuring Maven installation can still proceed even if ${SDKMAN_DIR}/var/platform was never created in the current run.

Changes:

  • Added get_sdkman_platform() to safely obtain the SDKMAN platform identifier with a uname-based fallback.
  • Updated find_version_list() to use the new helper instead of unconditionally reading ${SDKMAN_DIR}/var/platform.
  • Added a regression test scenario covering version: "none" with installMaven: true and a specific Maven version.
File summaries
File Description
src/java/install.sh Adds a platform-detection fallback so SDKMAN API calls don’t depend on var/platform being present.
test/java/scenarios.json Adds a scenario reproducing the “no Java install, but install Maven 3.8.8” case.
test/java/install_maven_specific_version_no_java.sh Adds a test asserting Maven 3.8.8 is installed successfully in the new scenario.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/java/install.sh Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Kaniska244

Copy link
Copy Markdown
Contributor

Copilot The patch version bump required for the java feature.

Co-authored-by: Kaniska244 <186041440+Kaniska244@users.noreply.github.com>

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot The patch version bump required for the java feature.

Bumped the Java feature patch version to 1.8.3 in 3cde164.

@Kaniska244
Kaniska (Kaniska244) marked this pull request as ready for review September 2, 2026 07:23
@Kaniska244
Kaniska (Kaniska244) requested a review from a team as a code owner September 2, 2026 07:23
@abdurriq
Abdurrahmaan Iqbal (abdurriq) merged commit fbd13b8 into main Sep 2, 2026
16 checks passed
@abdurriq
Abdurrahmaan Iqbal (abdurriq) deleted the copilot/fix-install-maven-error branch September 2, 2026 16:40
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

Successfully merging this pull request may close these issues.

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

4 participants