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

LSP support and hover not working on openSUSE Tumbleweed linux #7

Closed
FvD opened this issue Aug 3, 2024 · 4 comments
Closed

LSP support and hover not working on openSUSE Tumbleweed linux #7

FvD opened this issue Aug 3, 2024 · 4 comments

Comments

@FvD
Copy link

FvD commented Aug 3, 2024

The languageserver does not start on opensuse Linux: there is no autocomplete, and no hover info (both do work with the inbuilt Python LSP).

The R languageserver library(languageserver) is installed for the user, and for all users, and starts without errors when started manually in an R session.

When working with an R file, after installing zed-r the following will appear in the Zed.log.

2024-08-03T16:45:05.742464926-06:00 [ERROR] server container removal

Caused by:
    No such file or directory (os error 2)
2024-08-03T16:45:05.742504035-06:00 [INFO] starting language server "r_language_server", path: "/home/fvd/Desktop/test-r-project", id: 2
2024-08-03T16:45:05.765531802-06:00 [INFO] starting language server. binary path: "/usr/bin/R", working directory: "/home/fvd/Desktop/test-r-project", args: ["--slave", "-e", "languageserver::run()"]
2024-08-03T16:45:06.645954691-06:00 [ERROR] invalid LSP message header "\u{c}Content-Length: 871\r\n\r\n"
2024-08-03T16:45:06.646022258-06:00 [ERROR] failed to start language server "r_language_server": oneshot canceled
2024-08-03T16:45:06.64604856-06:00 [ERROR] server stderr: Some("")
2024-08-03T16:45:06.646074588-06:00 [INFO] retrying installation of language server "r_language_server" in 1s
2024-08-03T16:45:06.646101245-06:00 [ERROR] server shut down
2024-08-03T16:45:07.646137143-06:00 [INFO] About to spawn test binary
2024-08-03T16:45:07.646197478-06:00 [WARN] test binary failed to launch
2024-08-03T16:45:07.646231712-06:00 [WARN] test binary check failed
2024-08-03T16:45:07.646265687-06:00 [INFO] beginning to reinstall server
2024-08-03T16:45:07.646307036-06:00 [INFO] deleting server container
2024-08-03T16:45:07.64645322-06:00 [ERROR] server container removal

After trying to fix this in the settings, I reinstalled Zed to start again from scratch, with a clean settings json. The error is the same remainse the same.

Can you give me pointers how to debug this any further?

@ocsmit
Copy link
Owner

ocsmit commented Aug 4, 2024

At first glance it looks like it is connecting to languageserver because it is able to recieve messages from it, but I think it might be decoding them into utf-8 incorrectly. The content-length header ("\u{c}Content-Length: 871\r\n\r\n") appears to have a unicode formatting character appended to the front, which is odd.

The zed source (crates/lsp/src/input_handler.rs#L88) splits the message header by newlines and then looks for the header which starts with the "Content-Length: ". The first couple characters being inserted at the front are then causing it to error out since the pattern matching is unsuccesful.

I would look to see what the locale of your R installation is in (sessionInfo()) and the locale of your machine as well. Might give some clues? I could also be very wrong!

@FvD
Copy link
Author

FvD commented Aug 4, 2024

That's interesting, I had not spotted \u{c}. It does not appear to be my R session locale - and I keep my machines typically in en_US, even though I mostly work in Spanish. I have no clue where this character could come from.

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-suse-linux-gnu
Running under: openSUSE Tumbleweed

Matrix products: default
BLAS:   /usr/lib64/R/lib/libRblas.so
LAPACK: /usr/lib64/R/lib/libRlapack.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: America/Costa_Rica
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     methods   base

other attached packages:
[1] shiny_1.9.1     nvimcom_0.9-165

loaded via a namespace (and not attached):
 [1] compiler_4.4.1    magrittr_2.0.3    fastmap_1.2.0     R6_2.5.1
 [5] cli_3.6.3         promises_1.3.0    later_1.3.2       htmltools_0.5.8.1
 [9] tools_4.4.1       Rcpp_1.0.13       digest_0.6.36     xtable_1.8-4
[13] httpuv_1.6.15     lifecycle_1.0.4   mime_0.12         rlang_1.1.4
>

@FvD
Copy link
Author

FvD commented Aug 5, 2024

This was caused by my .Rprofile! I had a custom startup message and this was causing issues.

Thanks!

@FvD FvD closed this as completed Aug 5, 2024
@ocsmit
Copy link
Owner

ocsmit commented Aug 5, 2024

Ah good to know! Glad you were able to figure it out. I'll add a note to the readme stating that custom startup messages may cause issues!

ocsmit added a commit that referenced this issue Aug 5, 2024
Add caveat providing brief note about #7
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

2 participants