REditorSupport / REditorSupport/vscode-R
R language server in vscode does not work properly with conda environments
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 139
- Avg merge
- 2h 46m
- Merged PRs (30d)
- 5
Description
Describe the bug
Currently, to set up a conda environment with R in VS Code you need to:
conda create -n r443 -c conda-forge r-base=4.4.3- Modify workspace JSON settings by creating a
.vscode/settings.jsonfile and modifyingr.rpath.xxandr.rterm.windowsto point to appropriate R executable (always R) and terminal (e.g. default R, radian) - Use Python extension to do
Python: Select Interpreter...- this allows the R terminal to automicatically activate the conda environment prior to running code.
Now I have a functioning R terminal that can send code from VS code editor directly to terminal.
I then was getting errors such as:
Failed to get list of R functions. Make sure that jsonlite is installed and r.rpath.windows points to a valid R executable.
and issues with help:
Couldn't show help for path: /library/stats/html/stats-package.html
Which I realised were issues with R language server.
I also was getting the error when launching vscode: R Language Server (26808) exited with exit code 3221225781
This error is associated with missing DLLs. I found from this issue that this is due to missing DLLs available when doing conda activate r443 - R language server doesn't do this and therefore doesn't work.
A fix is to add these DLLs to PATH, (normally found in /c/Users/<>/miniconda3/envs/r443/Library/bin) and confirming with where libblas.dll in base environment.
Obviously, this is not desirable and it took me ages to figure all this out. Is there a way to run conda activate r443 prior to launching R language server to expose the appropriate DLLs?
P.S. - apologies if this is better suited for languageserver issues, I thought it probably was better suited here as it's regarding the launching and management of the extension via vscode-R.
Thanks!
settings.json:
{
"r.rpath.windows": "C:\\Users\\<>\\miniconda3\\envs\\r443\\Scripts\\R.exe",
"r.rterm.windows": "C:\\Users\\<>\\miniconda3\\envs\\r443\\Scripts\\radian.exe"
}
- OS: Windows
- VSCode Version: 1.100.3
- R Version: 4.4.3
- vscode-R version: 2.8.6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported .vscode/settings.json configuration and reproduce the R language server launch on Windows with the conda environment. Check the language server startup behavior alongside the missing-DLL and PATH errors described in the issue. Done means the server launches successfully and function lists and help work without manually adding conda DLL directories to PATH.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- anaconda, r, vscode
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100