asdf-java icon indicating copy to clipboard operation
asdf-java copied to clipboard

set-java-home.bash requires PWD change?

Open mgh520 opened this issue 5 years ago • 2 comments

Curious why this was changed to only update JAVA_HOME if PWD has changed. Maybe I'm doing something wrong but I'm trying to do this:

asdf global java adoptopenjdk-8.0.275+1.openj9-0.23.0
. ~/.asdf/plugins/java/set-java-home.bash

the path changes, so java-version shows 1.8, but JAVA_HOME does not change because I haven't changed directories.

Use case is something like this:

  1. change to my project directory
  2. run maven/java command
  3. "crap, this one requires jdk 8, not 11"
  4. run commands above to switch to jdk 8
  5. JAVA_HOME is not changed and command still fails

mgh520 avatar Jan 04 '21 21:01 mgh520

same issue

looks like it was designed that way

// the code from `~/.asdf/plugins/java/set-java-home.bash`
function _asdf_java_prompt_command() {
  if [[ "${PWD}" == "${LAST_PWD}" ]]; then
    return
  fi
  LAST_PWD="${PWD}"
  _asdf_java_update_java_home
}

NoSugarCoffee avatar Dec 07 '22 10:12 NoSugarCoffee

same issue

looks like it was designed that way

// the code from `~/.asdf/plugins/java/set-java-home.bash`
function _asdf_java_prompt_command() {
  if [[ "${PWD}" == "${LAST_PWD}" ]]; then
    return
  fi
  LAST_PWD="${PWD}"
  _asdf_java_update_java_home
}

Removing check condition seems to work, but I'm not sure if it makes sense

function _asdf_java_prompt_command() {
  #if [[ "${PWD}" == "${LAST_PWD}" ]]; then
  #  return
  #fi
  #LAST_PWD="${PWD}"
  _asdf_java_update_java_home
}

NoSugarCoffee avatar Dec 07 '22 10:12 NoSugarCoffee