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

Unrecognized option: -J-XX:ReservedCodeCacheSize=1024m #658

Open
ghostbuster91 opened this issue Mar 24, 2024 · 0 comments
Open

Unrecognized option: -J-XX:ReservedCodeCacheSize=1024m #658

ghostbuster91 opened this issue Mar 24, 2024 · 0 comments

Comments

@ghostbuster91
Copy link
Contributor

ghostbuster91 commented Mar 24, 2024

Describe the bug

When I launch a project that sets some1 jvm options in .jvmopts nvim-metals fails to start metals language server with a following message:

[ERROR][2024-03-24 14:50:05] .../vim/lsp/rpc.lua:734	"rpc"	"/nix/store/n02limb87mpqrw80pra80rwyyvzg28a3-metals-1.2.1/bin/metals"	"stderr"	"Unrecognized option: -J-XX:ReservedCodeCacheSize=1024m\nError: Could not create the Java Virtual Machine.\nError: A fatal exception has occurred. Program will exit.\n"

This is because nvim-metals assumes that metalsBinaryPath will point to a metals through coursier (or some other wrapper) and prefixes certain options with -J

for i, opt in ipairs(all_opts) do
-- In order to pass these options to coursier they need to be prefaced with `-J`
all_opts[i] = "-J" .. opt
end

I am not using coursier but pointing metalsBinaryPath to something like java -jar metals.jar ...

Expected behavior

I understand why it is that way. Coursier is the most popular, recommended and also the option of nvim-metals choice when it comes to installing metals.

I wouldn't be surprised if I was the only one person passing there something else2.

I know that as a workaround I can override metals_config.cmd instead of metalsBinaryPath and then I will be in charge of crafting the full command, but I wanted to avoid having to duplicate some of the nvim-metals code (like reading the jvmopts etc).

I am not sure what should be done here. I think that it would be a good idea to at least mention this in the documentation. Wdyt?

Update: I think that the ideal way would be to apply the jvm flags transformation only if metals is installed via coursier, otherwise flags should not be adjusted. The question is what to do with memory parameters in such approach.

Operating system

Linux

Version of Metals

1.2.1

Commit of nvim-metals

d90ea43

Footnotes

  1. Memory specific options are filtered out here https://github.com/scalameta/nvim-metals/blob/4f9bf0c821092f20dd34c1a4ea5b07b0500ff089/lua/metals/config.lua#L353-L360

  2. I am not https://sourcegraph.com/search?q=context%3Aglobal+metalsBinaryPath&patternType=keyword&sm=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant