valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
724 stars 33 forks source link

Unable to locate a Java Runtime error #187

Open Antomek opened 1 year ago

Antomek commented 1 year ago

First off, many thanks for your work on this wonderful LSP! I was using it very happily, but recently it stopped working for me.

Issue: ltex crashes upon starting

Immediately when opening a file that should trigger ltex, e.g. .tex, the server crashes.

This is the log output:

[ERROR][2022-09-15 18:59:18] .../vim/lsp/rpc.lua:420    "rpc"   "ltex-ls"   "stderr"    "The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java."

Steps to reproduce

The error is due to me not having a Java installation:

❯ java -version
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

However, this is slightly surprising to me as your README states:

Comes with everything included, no need to install Java or LanguageTool

I installed ltex-ls using Mason for neovim, so the problem may actually lie there, but until recently I had no issue using ltex.

Is this a case of MacOS users having to install Java manually anyway, or did something go awry somewhere?

Version information

LDAP commented 1 year ago

There are platform independent releases (without Java) and platform depended releases that come with Java.

Without knowing what the neovim plugin really does I suspect it just installs the platform independent release. I recommend checking out the plugin repo and open an issue there.

mattamizer commented 1 year ago

Out of curiosity are you on the ARM_64 Mac? I have the same issue on mine where running the exact same config with the exact same installation method on my Intel Mac works 100% fine. EDIT: Additionally installing Java using skdman doesn't fix the issue. Whatever is going on having Java installed doesn't seem to fix the issue.

mattamizer commented 1 year ago

As of this comment ltex-ls is working as expected for me. This can probably be closed?

dpo commented 1 year ago

@mattamizer Were you able to fix the issue? Could you please explain how?

The OP states that (s)he's on a M1 Mac, so yes, it's an Arm64 processor. I'm having the same problem (ltex-ls also installed from Mason for Neovim).

Thanks.

mattamizer commented 1 year ago

@mattamizer Were you able to fix the issue? Could you please explain how?

The OP states that (s)he's on a M1 Mac, so yes, it's an Arm64 processor. I'm having the same problem (ltex-ls also installed from Mason for Neovim).

Thanks.

Sure! The way I solved this on my M1 was the following.

  1. Uninstall/remove ltex-ls using :LspUninstall and remove any config from init.lua
  2. Install Java using sdk. I installed a few different versions based on projects I need to work on but I think the default is 17.0.1-open for me
  3. Reinstall ltex-ls using :LspInstall
  4. Add relevant configuration back to init.lua

I don't know if it was something I did or if something in Mason was updated in the meantime but it's working fine for me now.

dpo commented 1 year ago

Thanks! I followed those steps, except I installed the java runtime with brew install openjdk and put it on the PATH. Running ltex-ls --help gives

❯ ltex-ls --help                                                                                      1m 4s 18:05:06
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Usage: ltex-ls [-hV] [--[no-]endless] [--host=<host>] [--log-file=<logFile>]
               [--port=<port>] [--server-type=<serverType>]

So it seems to first fail ... and then work?!

Regardless, Neovim doesn't want it and complains that

[null-ls] failed to load builtin ltex_ls for method diagnostics
mattamizer commented 1 year ago

That's certainly interesting behavior. I'm not really sure what to make of that.

Littledarren commented 6 months ago

Mason.nvim will install platform independent ltex when using unix plat. review the default install path $HOME/.local/share/nvim/mason/packages/ltex-ls. The simplest way to solve this is mannully download the platform dependent ltex and replace the unarchived.

referer: https://github.com/williamboman/mason.nvim/issues/1531

chrisgrieser commented 5 months ago

I made a PR to mason (mostly) fixing the issue: https://github.com/mason-org/mason-registry/pull/4311

See the comment I made in the mason-thread, which details what you need to change in your config to use the bundles JRE in nvim: https://github.com/williamboman/mason.nvim/issues/1531#issuecomment-1913117887

chrisgrieser commented 5 months ago

The PR has been merged, so nvim users using mason should have no troubles anymore at all. (Download just takes a bit more time because of the bundles JRE).

(Only for Linux, the JRE is not bundled and must be set manually via JAVA_HOME)