Java or Groovy or Swift or Golang

How to update sdkman from gvm #groovy #sdkman


Today, I heard that gvm is replaced by sdkman.

Because there are go-lang tool called gvm (go-lang version manager) whose name conflicts gvm(Groovy enVironmental Manager).

For details you can find issue at sdkman repository.


In this entry, I'll explain how to update sdkman from gvm.

First Step

  • Run gvm selfupdate force.
~ $ gvm selfupdate force

GVM has been detected on your system...

This update will upgrade GVM to SDKMAN!

Do you want to continue with the upgrade? (Y/n) <<- entery Y


Successfully upgraded SDKMAN.

Please open a new terminal, or run the following in the existing one:

    export SDKMAN_DIR="/Users/name/.sdkman" && source "/Users/name/.sdkman/bin/sdkman-init.sh"

Second Step

  • Run command suggested by gvm selfupdate.
~ $ export SDKMAN_DIR="/Users/name/.sdkman" && source "/Users/name/.sdkman/bin/sdkman-init.sh"
~ $

Then you can run sdkman's command sdk command in the current terminal.

Third Step

  • Mark candidate version.

After updating to sdkman, current using candidate's version is lost.

For example, run sdk list gradle(currently I used gradle 2.7).

~ $ sdk list gradle

Available Gradle Versions
   * 2.7-rc-2             1.5                                                      
     2.7-rc-1             1.4                                                      
   * 2.7                  1.3                                                      
   * 2.6                  1.2                                                      
   * 2.5                  1.12                                                     


+ - local version
* - installed
> - currently in use

You can find that there are no mark of currently in use.

To fix this problem, run sdk default candidate version one by one.

In my case, I have used ...

  • gradle - 2.7
  • grooyv - 2.4.4
  • groovyserv - 1.0.0

So, I run these command.

$ sdk d gradle 2.7
$ sdk d groovy 2.4.4
$ sdk d groovyserv 1.0.0

Fourth Step

  • update .bashrc/.bash_profile to point sdkman directory and to call sdkman-init.sh.

The current updating script doesn't override .bashrc/.bash_profile file to call sdkman-init.sh.

So you have to write it by hand.

  1. Remove gvm's commands from .bashrc/.bash_profile.
  2. Add the following commands to .bashrc/.bash_profile.
export SDKMAN_DIR="/path/to/user-home/.sdkman"
[[ -s "/path/to/user-home/.sdkman/bin/sdkman-init.sh" && -z $(which sdkman-init.sh | grep '/sdkman-init.sh') ]] && source "/path/to/user-home/.sdkman/bin/sdkman-init.sh"


If you use gradle on daemon mode, a build might fail with following message.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'javajo-gradle'.
> java.io.FileNotFoundException: /path/to/user/.gvm/gradle/2.7/lib/plugins/gradle-diagnostics-2.7.jar (No such file or directory)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


This error happens because Gradle tries to use compiled cache already exist.

To avoid this error, stop daemon, and restart daemon.

The command to stop Gradle daemon is as follows.

$ gradle --stop

After running this command, run gradle with daemon mode, build will finish in success.