Ignore missing JAR in native installations (allows installation of jdtls through NixOS) #497
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Do not check for the existence of a JAR if a native command is preferred and there is a suitable executable.
I was hit by this issue on NixOS which puts the JAR at a different location than the auto detection of this package expects it. The alternative, setting
lsp-java-server-install-dir
such that the JAR instead of the executable is found, leads to a failure. When the JAR is launched directly, jdtls tries to write to the Nix Store which is read-only. Launching the jdtls executable provided by nixpkgs works perfectly though.The error I encountered was exactly the same as described in #421. Hence, I believe this PR fixes that issue without overriding any private functions in the user configuration (see below).
As I understand it, this is also the alternative solution for #487 as suggested by @LuigiPiucco in #487 (comment)
In case this is desired, I could also add a default fallback in
lsp-java--locate-server-command
iflsp-java-jdt-ls-prefer-native-command
ist
andlsp-java-jdt-ls-command
is found inexec-path
.Working NixOS configuration
When installing
jdtls
globally, my working configuration after this PR looks like this:Note that
jdt-language-server
was renamed tojdtls
in nixpkgs. In case you are using some old nixpkgs version, you also needbefore the first two lines.
If you want to use nix shells with direnv, you can follow the guide by @dschrempf and use the following Emacs configuration: