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

[coc.nvim]: UnhandledRejection: TypeError: Cannot read properties of null (reading '0') #267

Open
sify21 opened this issue Oct 13, 2023 · 8 comments

Comments

@sify21
Copy link

sify21 commented Oct 13, 2023

os

Ubuntu 23.04 (Lunar Lobster)

:CocInfo

## versions

vim version: VIM - Vi IMproved 9.0 9001189
node version: v18.17.1
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /home/sify/.vim/plugged/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2023-10-13T17:14:08.656 INFO (pid:32982) [plugin] - coc.nvim initialized with node: v18.17.1 after 97
2023-10-13T17:14:08.756 ERROR (pid:32982) [server] - unhandledRejection  Promise {
  <rejected> TypeError: Cannot read properties of null (reading '0')
      at lombokPath2Version (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23277:56)
      at lombokPath2VersionNumber (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23281:30)
      at addLombokParam (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23308:35)
      at prepareParams (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23554:5)
      at prepareExecutable (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23478:21)
      at StandardLanguageClient.initialize (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:28729:25)
      at async startStandardServer (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:29671:3)
      at async /home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:29654:9
} TypeError: Cannot read properties of null (reading '0')
    at lombokPath2Version (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23277:56)
    at lombokPath2VersionNumber (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23281:30)
    at addLombokParam (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23308:35)
    at prepareParams (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23554:5)
    at prepareExecutable (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:23478:21)
    at StandardLanguageClient.initialize (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:28729:25)
    at async startStandardServer (/home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:29671:3)
    at async /home/sify/.config/coc/extensions/node_modules/coc-java/lib/index.js:29654:9

java-related coc-settings.json

    "java.jdt.ls.java.home": "/home/sify/.asdf/installs/java/temurin-17.0.8+7",
    "java.jdt.ls.vmargs": "-javaagent:/home/sify/.config/coc-lsp/lombok.jar",
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-1.8",
            "path": "/home/sify/.asdf/installs/java/temurin-8.0.382+5"
        },
        {
            "name": "JavaSE-17",
            "path": "/home/sify/.asdf/installs/java/temurin-17.0.8+7",
            "default": true
        }
    ],

@ggascon
Copy link

ggascon commented Oct 18, 2023

A workaround is to comment this line:
"java.jdt.ls.vmargs": "-javaagent:/home/sify/.config/coc-lsp/lombok.jar",
in coc-settings.json

@sify21
Copy link
Author

sify21 commented Oct 19, 2023

Then how to specify lombok location to coc-java?

@Henry-Savary-Jackson
Copy link

Try adding the version number of lombok to the actual lombok jar filename. For example changing "lombok.jar" to "lombok-1.18.28.jar". Make sure to follow to format precisely.
Hope this helps! :)

@ghost
Copy link

ghost commented Nov 11, 2023

Try adding the version number of lombok to the actual lombok jar filename. For example changing "lombok.jar" to "lombok-1.18.28.jar". Make sure to follow to format precisely. Hope this helps! :)

This is insane. It works.

@EvandroLG
Copy link

Wow! It worked out! o.O

@trev-dev
Copy link

trev-dev commented Mar 24, 2024

https://github.com/neoclide/coc-java/blob/master/src/lombokSupport.ts#L24 We're using regex to "validate" the lombok version.

Funny thing is I used nix to supply the lombok, and this regex parsed my javaagent and found the version tag in the path, rather than the filename, and said it was the wrong version.

I think there must be a better way to validate (or not validate) the lombok version.

@trev-dev
Copy link

Hey so easy workaround, set this: "java.jdt.ls.lombokSupport.enabled": true - and remove the javaagent flag from the vmargs. I don't remember this working well for myself in the past, but it works now.

Also, if you want to use your own version of lombok, this works: #240 (comment)

@medwards
Copy link

Same as trev-dev, I get this error when my settings are:

"java.jdt.ls.lombokSupport.enabled": true,
"java.jdt.ls.vmargs": "-javaagent:/home/medwards/.local/share/lombok/lombok.1.18.24.jar"

Disabling Lombok support ends up working fine.

Removing vmargs will not crash the LSP anymore, but it will not process the lombok annotations either - I have to add the lombok jar to ~/.config/coc/extensions/node_modules/coc-java/lombok/

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

6 participants