Skip to content

fix: discover SDKMAN Java when starting the shell launcher - #6858

Open
mvanhorn wants to merge 2 commits into
HMCL-dev:mainfrom
mvanhorn:fix/4574-sdkman-bootstrap-java-discovery
Open

mvanhorn wants to merge 2 commits into
HMCL-dev:mainfrom
mvanhorn:fix/4574-sdkman-bootstrap-java-discovery

Conversation

@mvanhorn

Copy link
Copy Markdown

Add a Linux/macOS fallback directly to HMCLauncher.sh after the existing lookup branches and before the Java-not-found warning, resolving SDKMAN's selected candidates/java/current/bin/java from a nonempty SDKMAN_DIR or, when unset/empty, a nonempty HOME plus .sdkman. The reporter cannot start HMCL-3.6.18.297.sh on Ubuntu 25.04 after installing Java through SDKMAN, with both Dragonwell 21 and Liberica 25 reported affected.

Reproduce the missing branch on Linux with JAVA_HOME and HMCL_JAVA_HOME absent and a controlled PATH containing only the bootstrap's required non-Java utilities: a temporary .sdkman/candidates/java/current symlink targets an executable stub, and startup selects it successfully; establish that the existing script fails this scenario before the fix; Verify custom SDKMAN_DIR and SDKMAN_CANDIDATES_DIR roots, including spaces in the root and launcher filename; empty SDKMAN variables fall back appropriately, while an absent/empty HOME must never trigger a relative lookup in the working directory.

Closes #4574

@github-actions github-actions Bot added the 100+ label Sep 12, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need this file? Is there any connection between bash and java🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why do we need this file? Is there any connection between bash and java🤔

看起来是 AI 生成的内容。

zkitefly and Glavo both questioned why a Java test drives the bash
launcher script. The harness does not belong in this PR; the SDKMAN
discovery fix in HMCLauncher.sh stands on its own.
@github-actions github-actions Bot added 10+ and removed 100+ labels Sep 17, 2026
@mvanhorn

Copy link
Copy Markdown
Author

You're both right — there's no good reason for a Java test to drive the bash launcher, and the file shouldn't have been in this PR. I've dropped it in e16dc10.

What's left is the 16 lines in HMCLauncher.sh: check SDKMAN_CANDIDATES_DIR, then SDKMAN_DIR/candidates, then ~/.sdkman/candidates, and exec that java if it's executable. It follows the same shape as the javavm branch just above it and doesn't source any shell startup files. Happy to drop the whole PR if you'd rather not carry SDKMAN handling in the launcher at all.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] HCML 识别不到已经安装的 Java,无法启动

3 participants