I can't attach any R session to VS Code when using a remote server via SSH and it can't find the binary either.
See original GitHub issueI am using a conda
virtual environment for a research project conducted at a remote server which I access via SSH.
I use the [Remote SSH] (https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh) extension to connect to the host and then I need to edit R
files there. The code below shows that both R
and radian
are correctly set, I believe:
(r_conda) [rgr6291@klc0201 bin]$ conda env list
# conda environments:
#
fomc /home/rgr6291/.conda/envs/fomc
r_conda * /home/rgr6291/.conda/envs/r_conda
rfe_paper /home/rgr6291/.conda/envs/rfe_paper
base /software/python-anaconda3/2019.10
(r_conda) [rgr6291@klc0201 bin]$ which R
~/.conda/envs/r_conda/bin/R
(r_conda) [rgr6291@klc0201 bin]$ which radian
~/.conda/envs/r_conda/bin/radian
In the settings for the R
extension, I have set these binaries as the RPath and the Rterm:
{
"r.rpath.linux": "~/.conda/envs/r_conda/bin/R",
"r.rterm.linux": "~/.conda/envs/r_conda/bin/radian"
}
However, I get errors like this one when I try to attach an R session:
Cannot find R client at ~/.conda/envs/r_conda/bin/radian. Please check r.rterm setting.
And also it complains that it can’t find the jsonlite package although it has been installed:
Failed to get list of R functions. Make sure that
jsonlite
is installed and r.rpath.linux points to a valid R executable.
What am I missing here?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:19 (6 by maintainers)
Hi !
My environment is the same as raulguarini (OP): VsCode + R extension + SSH remote shell (Linux) + R only available through a Conda environment on the remote. I haven’t tried to use radiant. After struggling a bit I just found how to use the Conda env properly, so I’m sharing it here.
In my case, the Conda environment also contains R packages (tidyverse etc) and an ODBC driver that I need to use from R. In order to use syntax highlighting from VsCode, I installed
r-languageserver
andr-jsonlite
in my Conda environment.Three options: the first one is a bit easier but not complete enough for me. I went for Option 3.
I hope this can help someone else! If so, maybe document it somewhere? Pierre
Option 1
In the settings for the R extension, set RPath and the Rterm: (NB: I avoided “~” in the paths, not sure if expansion would work or not)
Result: R is available, tidyverse also OK but not the ODBC driver is not accessible from R.
Option 2
As suggested in #623, you can try to set
"r.alwaysUseActiveTerminal": true
in the VsCode settings. Then manually start a terminal, Conda-activate and start R. After that you should be able to submit R commands (e.g. with Ctrl+Enter). I find it less comfortable and didn’t try it.Option 3
Write a little shell script which first activates Conda and then starts R. I wrote it in
/path/to/myproject/R-conda.sh
and made it executable (chmod +x R-conda.sh
)Then I pointed VsCode-R to this script in the settings:
Result: R is available, tidyverse and the ODBC driver are accessible from R.
Just came across this problem, I also used conda to manage R in a remote server. Since the server has network limitations and I have no root permission, I can only work R with a conda, and set some local CRAN or Bioconductor mirror to install packages. here is the detail usage list:
install.package
(since I don’t want to use conda to manage R packages)Rterm
here is my sessionInfo() output:
I install R by command
conda create --name R-release -c conda-forge r-base git radian
here is my setting:.bashrc
setting: