-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metals-vscode incorrectly assumes java home directory. #1528
Comments
Thanks for reporting! How does the directory structure look like for |
Yeah,
Running the |
If JAVA_HOME is actually not needed then running |
We should be fine just fixing the logic to not assume we're in bin/java. We could possibly do the fix for Java sources inside metals server as a fallback. So we wouldn't need to invoke anything before actually starting metals. |
Describe the bug
Using asdf to manage jvm installs, vs code incorrectly assumes that a java reference found on
$PATH
has a home directory under<detected-java-path>/../..
This happens here:
metals-vscode/packages/metals-languageclient/src/getJavaHome.ts
Line 66 in 5130d1d
It then blindly tries to run
<detected-java-path>/../../bin/java
which fails.To Reproduce Steps to reproduce the behavior:
asdf
: https://asdf-vm.com/guide/getting-started.htmlasdf plugin add java
asdf install java zulu-21.36.19
asdf global java zulu-21.36.19
Expected behavior
If the actual JAVA_HOME is needed it could be found using something like this very hacky method I just pieced together:
echo 'System.getProperty("java.home")' | jshell -q 2>&1 | sed -n '1p' | sed -ne 's/^.*==> //p'
The
jshell
command should be located on $PATH as previously. Note that this imposes a delay of ~1.5 seconds on my setup.Screenshots
Installation:
Additional context
Search terms
java, jvm, javaHome, JAVA_HOME
The text was updated successfully, but these errors were encountered: