jabba icon indicating copy to clipboard operation
jabba copied to clipboard

Jabba use does not alter environment on macOS

Open rubin55 opened this issue 6 years ago • 6 comments

See below for command line session; this is on macOS Mojave 10.14.5 with AdoptOpenJDK 8 and 11, openj9 variants:

$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b03)
Eclipse OpenJ9 VM (build openj9-0.14.0, JRE 1.8.0 Mac OS X amd64-64-Bit 20190417_48 (JIT enabled, AOT enabled)
OpenJ9   - bad1d4d06
OMR      - 4a4278e6
JCL      - 5590c4f818 based on jdk8u212-b03)
$ jabba --version
0.11.2
$ jabba link system@8 /Library/Java/JavaVirtualMachines/jdk8u212-b03
$ jabba link system@11 /Library/Java/JavaVirtualMachines/jdk-11.0.3+7
$ jabba use system@11
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b03)
Eclipse OpenJ9 VM (build openj9-0.14.0, JRE 1.8.0 Mac OS X amd64-64-Bit 20190417_48 (JIT enabled, AOT enabled)
OpenJ9   - bad1d4d06
OMR      - 4a4278e6
JCL      - 5590c4f818 based on jdk8u212-b03)

I.e, java version does not change, I expect the second invocation of java -version to come from the JDK represented by system@11.

rubin55 avatar May 21 '19 11:05 rubin55

Same problem here.

ehrlichja avatar Jun 09 '19 16:06 ehrlichja

If you installed Jabba through homebrew, that's could be the issue, the install method listed on github (wget piped into bash) works correctly and sets up some shell integrations, but the homebrew install does not :( (see also https://github.com/shyiko/jabba/issues/138)

pyoio avatar Jun 12 '19 21:06 pyoio

Fyi, I did not install through homebrew but using wget.

rubin55 avatar Jun 13 '19 07:06 rubin55

I uninstalled homebrew version and installed using the official wget method. That fixed the issue and now jabbba updates my local path to the desired java binary.

ehrlichja avatar Jun 15 '19 19:06 ehrlichja

:/ Not in a habit of doing curl | bash very often. Might be good to publish what extra setup the script does

YarekTyshchenko avatar Oct 24 '19 14:10 YarekTyshchenko

I wound up just adding the following to my .zshrc until this is resolved:

JABBA_HOME=$HOME/.jabba
JABBA_HOME_TO_EXPORT=\$HOME/.jabba

_jabba() {
    local fd3=$(mktemp /tmp/jabba-fd3.XXXXXX)
    (JABBA_SHELL_INTEGRATION=ON `which jabba` "$@" 3>| ${fd3})
    local exit_code=$?
    eval $(cat ${fd3})
    rm -f ${fd3}
    return ${exit_code}
}

if [ ! -z "$(_jabba alias default)" ]; then
    _jabba use default
fi

This is just a slight modification of what's done in the install script: https://github.com/shyiko/jabba/blob/master/install.sh#L134

perryao avatar Apr 29 '21 15:04 perryao