Coursier: /usr/libexec/java_home does not work with Java installed via coursier

Created on 24 Apr 2020  路  6Comments  路  Source: coursier/coursier

Steps

~ eval "$(cs java --jvm 11 --env)"
~ java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)
~ /usr/libexec/java_home
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
~

Most helpful comment

I see. Will raise an issue in jep repo then. They should be directly using the value of $JAVA_HOME rather than replying on /usr/libexec/java_home

All 6 comments

BTW, cs java-home works as expected.

The problem is, a third party program is using /usr/libexec/java_home to determine JAVA_HOME and that can not be altered.

Any workaround possible?

One more thing, the external program is jep. And pip install jep throws:

Collecting jep
  Using cached jep-3.9.0.tar.gz (3.0 MB)
    ERROR: Command errored out with exit status 1:
     command: /Users/mushtaqahmed/Downloads/polynote/.venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/8d/nrdzx4s96fnchgk89vlcbbyh0000gn/T/pip-install-47z9ggl5/jep/setup.py'"'"'; __file__='"'"'/private/var/folders/8d/nrdzx4s96fnchgk89vlcbbyh0000gn/T/pip-install-47z9ggl5/jep/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/8d/nrdzx4s96fnchgk89vlcbbyh0000gn/T/pip-install-47z9ggl5/jep/pip-egg-info
         cwd: /private/var/folders/8d/nrdzx4s96fnchgk89vlcbbyh0000gn/T/pip-install-47z9ggl5/jep/
    Complete output (9 lines):
    numpy include found at /Users/mushtaqahmed/Downloads/polynote/.venv/lib/python3.7/site-packages/numpy/core/include
    Traceback (most recent call last):
      File "/private/var/folders/8d/nrdzx4s96fnchgk89vlcbbyh0000gn/T/pip-install-47z9ggl5/jep/commands/java.py", line 36, in get_java_home
        result = shell('/usr/libexec/java_home')
      File "/private/var/folders/8d/nrdzx4s96fnchgk89vlcbbyh0000gn/T/pip-install-47z9ggl5/jep/commands/util.py", line 104, in shell
        raise CommandError(message=msg, result=result)
    commands.util.CommandError: Encountered an error (return code 1) while executing '/usr/libexec/java_home'
    Error:
    Include folder should be at '/System/Library/Frameworks/JavaVM.framework/Headers' but doesn't exist. Please check you've installed the JDK properly.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

AFAIU, /usr/libexec/java_home is mostly for JVMs installed under /Library/Java/JavaVirtualMachines. It doesn't take into account JAVA_HOME, which is the env var we're using here to set the JVM. sdkman is having the same issue.

I see. Will raise an issue in jep repo then. They should be directly using the value of $JAVA_HOME rather than replying on /usr/libexec/java_home

This issue also affects does usage of Ammonite scripts in IntelliJ.

I opened an issue here: https://youtrack.jetbrains.com/issue/SCL-18258

Request others who is encountering this to please upvote there.

@alexarchambault Any suggestions on how to workaround this in IntelliJ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryan-williams picture ryan-williams  路  5Comments

alexandru picture alexandru  路  6Comments

fommil picture fommil  路  4Comments

mosesn picture mosesn  路  6Comments

davidmlw picture davidmlw  路  4Comments