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

language server tooltips, colour picker, etc. not working after updating to R 4.2. #563

Closed
bighungryjames opened this issue Jul 22, 2022 · 13 comments

Comments

@bighungryjames
Copy link

bighungryjames commented Jul 22, 2022

image

language server tooltips are not working after updating R.

One of the Bioconductor packages I needed required updating R to latest version (4.2.1 currently), so I updated R using "installr" package. (Which could have been the problem.) Last version I used was R 4.1.2.

After the update, I re-opended the vscode, and noticed that all of the language server functionalities stopped working. The affected functionalities include function definition tooltips (as on the image above), colour picker.

I tried changing my network connection from my workplace's to my private one, but that did not affected anything.

I also tried relocating the languageserver lib from the default lib (C:/Program Files/R/R-4.2.1/library) to a directory inside My Documents via languageserversetup package, but that did not do anything either. Note that I also fixed the .Rprofile problem by appending the following code (I reversed slashes in the address in the code so that the directory separators work as intended):

# LanguageServer Setup Start (do not change this chunk)
# to remove this, run languageserversetup::remove_from_rprofile
if (requireNamespace('languageserversetup', quietly = TRUE)) {
  options(langserver_library = 'C:/Users/*****/Documents/languageserver-library')
  languageserversetup::languageserver_startup()
  unloadNamespace('languageserversetup')
}
# LanguageServer Setup End
@bighungryjames bighungryjames changed the title language server tooltips, autocomplete, etc. not working after updating to R 4.2. language server tooltips, colour picker, etc. not working after updating to R 4.2. Jul 22, 2022
@bighungryjames
Copy link
Author

UPDATE: The problem disappeared as I reverted R to version 4.1.2. I guess this was a problem of version incompatibility. Since I have to use some packages in R 4.2.1 environment, I wish this issue is handled swiftly.

@renkun-ken
Copy link
Member

Are you using the same library path with different R versions? Some packages with compiled code might not work properly if it is the case.

@bighungryjames
Copy link
Author

Are you using the same library path with different R versions? Some packages with compiled code might not work properly if it is the case.

Well, could you elaborate on the library path part? Before reverting to R 4.1.2, I was using R 4.2.1 and I uninstalled all the previous versions of R, reinstalling the packages I use via install.packages(). That being said, I also changed the vscode preferences r.path (or something like that) from 4.1.2 to 4.2.1.

The library paths I use are the default ones, C:/Program Files/R/R-***/library.

@bighungryjames
Copy link
Author

Something is seriously wrong here, as I noticed that if I remove the 4.2.1 library directories at C:\Program Files\R\R-4.2.1\library\languageserver, suddenly the 4.1.2 R loses the ability to do the language server jobs. Weird...

@renkun-ken
Copy link
Member

Sounds like it is caused by your usage of languageserversetup? Would you try not using it and keep .Rprofile clean and install langaugeserver to your version-specific library path?

@bighungryjames
Copy link
Author

Thank you for the quick responses. You're my savior! I deleted the languageserversetup package and the private library it created. Re-installing the languageserver without the languageserversetup restored the tooltips in R .1.2 environment.

However, I am not sure about the R 4.2.1. Is the current CRAN version of language server not compatible with R 4.2?

@bighungryjames
Copy link
Author

bighungryjames commented Jul 22, 2022

image
UPDATE: When I removed everything (including manually deleting the entire library directories in my C drive) and cleanly install R 4.2.1 and Rtools 42, The tooltip disappearing still exists and the colour picker is not there. However, the r environment watching (the right panel with the global environment variables etc.) are working fine.

It seems there is some incompatibility between R 4.2.1 and the current languageserver.

@renkun-ken
Copy link
Member

Would you like to enable r.lsp.debug in vscode and go to "Output" -> "R Language Server" and see if there is an error when vscode-R tries to spawn a language server process.

@bighungryjames
Copy link
Author

bighungryjames commented Jul 22, 2022

Thank you for the guides! It says as the following:
R language server (undefined) started

@bighungryjames
Copy link
Author

I tried (from searching similar cases) running the languageserver manually:
languageserver::run(debug=TRUE)
However, the following Error message appears:

> languageserver::run(debug=TRUE)
[2022-07-22 21:58:30.954] connection type: stdio
[2022-07-22 21:58:31.519] Error: stdin connection close
Call: stdin_read_line()
Stack trace:
1: stdin_read_line()
2: self$read_line()
3: self$read_header()
4: self$fetch(blocking = FALSE)
[2022-07-22 21:58:31.604] exiting

@renkun-ken
Copy link
Member

Does it work if you run

languageserver::run(debug=TRUE, port = 13579)

What's your vscode settings of vscode-R extension (r.*)?

@bighungryjames
Copy link
Author

Does it work if you run

languageserver::run(debug=TRUE, port = 13579)

What's your vscode settings of vscode-R extension (r.*)?

Thank you very much!!!!!
The problem was the vscode settings. The JSON file contained the following lines:

    "r.rpath.windows": "C:\\Program Files\\R\\R-4.1.2\\bin\\x64\\R.exe",
    "r.rterm.windows": "C:\\Program Files\\R\\R-4.2.1\\bin\\x64\\R.exe",
    "files.associations": {
        "*.rmd": "markdown"
    },
    "r.libPaths": [
        "C:\\Program Files\\R\\R-4.2.1\\library\\"
    ],
    "r.lsp.debug": true

So I changed the rpath to "C:\\Program Files\\R\\R-4.2.1\\bin\\x64\\R.exe" and re-loaded vscode. That fixed everything! Thank you very, very much.

In the meantime, as a newbie coder in R and python, maybe I should get more used to this vscode development environments. Thank you for all your time!

@renkun-ken
Copy link
Member

Glad to know it works for you now.

The experience of using multiple versions of R might be improved via REditorSupport/vscode-R#1143.

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