Skip to content

Bug: Incorrect "sdk current" output after using sdk use #1485

@lucaspottersky

Description

@lucaspottersky

Bug report
After switching Java versions with sdk use, SDKMAN prints that the new version is active, but sdk current still shows the old version. However, which java confirms the new version is actually in use. This causes inconsistent reporting of the active candidate.

To reproduce

  • Run sdk current and observe the currently active candidates.
  • Execute sdk use java 21.0.2-open
  • Observe the message: "Using java version 21.0.2-open in this shell."
  • Run sdk current again — it still shows java 17.0.17-tem instead of the newly selected version.
  • Run which java — it correctly points to the Java 21.0.2-open binary.
$ sdk current 
Current versions in use:
java 17.0.17-tem

$ sdk use java 21.0.2-open 
Using java version 21.0.2-open in this shell.

$ sdk current
Current versions in use:
java 17.0.17-tem

$ which java
/home/user/.sdkman/candidates/java/21.0.2-open/bin/java

Expected behavior:
sdk current should reflect the version selected by sdk use for the current shell session.

System info

$ lsb_release -a
Description:	Ubuntu 22.04.5 LTS

$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

$ sdk version
SDKMAN!
script: 5.20.0
native: 0.7.14 (linux x86_64)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions