Skip to content

JBang should reuse installed SDKMAN JDK (java 25+) instead of downloading another JDK #2400

Description

@ayagmar

Summary

When running a catalog entry requiring java: 25+, JBang may download a new JDK even if Java 25 is already installed via SDKMAN.

Environment

  • OS: 6.19.2-2-cachyos
  • SDKMAN installed JDKs:
    • 21-tem (current)
    • 25.0.1-tem
  • Command:
    • jbang --verbose run --fresh demos@tamboui --help

Expected

JBang detects and uses installed SDKMAN Java 25 (~/.sdkman/candidates/java/25.0.1-tem) without downloading.

Patch:
Image

Actual

JBang may attempt JDK installation instead of reusing SDKMAN Java 25.

Image Image

Repro

  1. Ensure SDKMAN has Java 25 installed but current Java is 21:
    • ❯ ls -1 ~/.sdkman/candidates/java
    • sdk use java 21-tem
  2. Run:
    • JBANG_DIR=$(mktemp -d) jbang --verbose run --fresh demos@tamboui --help
  3. Check verbose output for install/download activity.

Root cause (from investigation)

This is in devkitman integration:

  • SDKMAN provider not part of basic provider set.
  • SDKMAN folder/ID handling needed to support normal SDKMAN folder names while preserving provider-unique IDs.

Proposed fix

  • Include sdkman in default/basic provider list.
  • Accept SDKMAN folder names like 25.0.1-tem.
  • Resolve both suffixed/unsuffixed IDs consistently.
  • Ignore current symlink and same-folder duplicates.
  • Add tests

Validation

With patched devkitman + jbang:

  • Verbose output includes SdkmanJdkProvider.
  • Selected JDK is 25.0.1-tem-sdkman at ~/.sdkman/candidates/java/25.0.1-tem.
  • No download/install occurs.

I have a working commit, I am happy to open PRs to devkitman + jbang to patch version and align breaking changes ( 0.3 to 0.4 )
Let me know what you think

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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