Skip to content
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

Java error: ENOENT: no such file or directory, lstat '../libexec/openjdk.jdk/Contents/Home/bin/java' #601

Closed
pjlsergeant opened this issue Oct 8, 2021 · 9 comments · Fixed by #603
Labels
bug Something isn't working upstream
Milestone

Comments

@pjlsergeant
Copy link

The project proudly exclaims:

NO LONGER REQUIRES JAVA! since v0.15.0

However, attempting to install v0.18.0 from inside VS Studio Code gives me an Error in Runtime Status:

ENOENT: no such file or directory, lstat '../libexec/openjdk.jdk/Contents/Home/bin/java'

My Java knowledge is non-existant, but that sure looks like it's trying (and failing) to load Java? Any pointers?

@pjlsergeant
Copy link
Author

Explicitly adding java.home in my settings has fixed the issue, but again, seems weird after the description of not requiring Java.

@pjlsergeant
Copy link
Author

Version: 1.61.0
Commit: ee8c7def80afc00dd6e593ef12f37756d8f504ea
Date: 2021-10-07T18:11:58.853Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0

@angelozerr
Copy link
Contributor

Explicitly adding java.home in my settings has fixed the issue, but again, seems weird after the description of not requiring Java.

Our XML Language Service is written in Java, but we provide a binary of this XML Language Server, it's the reason why we say "doesn't require java". The only problem with binary that it loose the capability to extends vscode-xml with a custom vscode extension to manage your own completion, validation, etc inside XML. That's why we give give the capability to use vscode-xml with Java.

The strategy to know if binary or Java XML Language Server must be used is the following:

  • No Java found -> Binary is used
  • Java found -> Java XML LS is used

You can force to use Binary if you wish (I think you should do that) https://github.com/redhat-developer/vscode-xml/blob/master/docs/Preferences.md#server-binary-mode

@pjlsergeant
Copy link
Author

pjlsergeant commented Oct 9, 2021

What's the strategy for seeing if Java is found, and could it be switched to one that looks to see if the user has attempted to setup Java in VS Code? Perhaps sensing on "java.home" or similar being set? Honestly, I had no idea Java was installed on my system

@rgrunber
Copy link
Member

Interesting that https://github.com/redhat-developer/vscode-quarkus/issues/403#issuecomment-937615201 has the exact same error. I suppose the only thing in common is their Java finding logic.

Both issues seem to be happening on MacOS. Could the installed directory structure be a little different there and we're not handling some case correctly ?

@angelozerr
Copy link
Contributor

angelozerr commented Oct 15, 2021

Both issues seem to be happening on MacOS.

@fbricon can you reproduce it?

@fbricon
Copy link
Collaborator

fbricon commented Oct 15, 2021

nope. this might be linked to a specific way of installing a JDK. If @pjlsergeant or @sebastienblanc can provide more info on how it was installed, it'd be helpful.

@pjlsergeant
Copy link
Author

pjlsergeant commented Oct 15, 2021

Mine is installed via brew. However, the following looks interesting:

$ which java
/usr/local/opt/openjdk/bin/java
$ ls -l $(which java)
lrwxr-xr-x  1 pjlsergeant  staff  45 10 Dec  2020 /usr/local/opt/openjdk/bin/java -> ../libexec/openjdk.jdk/Contents/Home/bin/java

and this specifically takes us back to the original error:

ENOENT: no such file or directory, lstat '../libexec/openjdk.jdk/Contents/Home/bin/java'

in short: it looks like there's some very weird symlink tomfoolery going on?

@rgrunber
Copy link
Member

rgrunber commented Oct 15, 2021

I'm able to reproduce on Linux now. I still say this is a bit of an oddity with symlinks we don't seem to support, but maybe we can do it easily.

The part that seems odd to me is the fact that the actual java binary itself is symbolically linked. Normally it's the path to JAVA_HOME folder that is symlinked. In your case I would expect /usr/local/opt/openjdk/ to symlink to some other folder.

So I created a setup where I have a JAVA_HOME of /usr/lib/jvm/java-11-openjdk , and under bin, I replaced java with a symlink to ../bin/java.old (the original binary).

I suspect this is happening in find-java-home

Exception has occurred: Error: ENOENT: no such file or directory, lstat '../bin/java.old'
t lstatSync (fs.js:1077:3)
    at Object.lstatSync (electron/js2c/asar_bundle.js:5:3528)
    at findLinkedFile (/home/rgrunber/git/vscode-xml/dist/extension.js:14318:13)
    at findLinkedFile (/home/rgrunber/git/vscode-xml/dist/extension.js:14320:12)
    at findLinkedFile (/home/rgrunber/git/vscode-xml/dist/extension.js:14320:12)
    at findLinkedFile (/home/rgrunber/git/vscode-xml/dist/extension.js:14320:12)
    at /home/rgrunber/git/vscode-xml/dist/extension.js:14216:24
    at /home/rgrunber/git/vscode-xml/dist/extension.js:44717:18
    at FSReqCallback.oncomplete (fs.js:184:5)
    at FSReqCallback.callbackTrampoline (internal/async_hooks.js:131:14)

Update : But findLinkedFile doesn't exist in latest find-java-home! Looks like our issue was fixed in jsdevel/node-find-java-home#32 ( jsdevel/node-find-java-home@b0e43bd ) , so upgrading to at least 1.2.1 (we're on 1.1.0) should fix this!

rgrunber added a commit to rgrunber/vscode-xml that referenced this issue Oct 15, 2021
- Fixes redhat-developer#601
- Update find-java-home to benefit from fix that correctly resolves
  relative symbolic links

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
@rgrunber rgrunber added bug Something isn't working upstream labels Oct 15, 2021
@rgrunber rgrunber added this to the 0.18.1 milestone Oct 15, 2021
angelozerr pushed a commit that referenced this issue Oct 18, 2021
- Fixes #601
- Update find-java-home to benefit from fix that correctly resolves
  relative symbolic links

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants