randy3k / radian

A 21 century R console
MIT License
2k stars 76 forks source link

Make which R version `R: Create R Terminal` opens dependent on VS Code settings #333

Closed MiguelRodo closed 2 years ago

MiguelRodo commented 2 years ago

Hi. Thank you for the great console!

In VS Code, I want radian to open a particular R version when running R: Create R Terminal based on the VS Code settings. For example, I can set the workspace settings in one project to use R 4.1.1 but in another to use R 3.6.3.

So, in settings.json I used the following settings:

"r.rterm.windows": "C:\\Users\\migue\\anaconda3\\Scripts\\radian.exe", 
"r.rpath.windows": "C:\\Program Files\\R\\R-4.1.1\\bin\\R.exe"

However, it always opens R 3.6.3. Based on here, I suppose that is because the binary to R version 3.6.3 and not R 4.1.1 is exposed in the PATH variable, and so Radian uses that automatically (and ignores r.rpath.windows).

I see that within settings.json, I can provide arguments to the command to open the terminal via r.rterm.option (as I understand it). So, I added the --r-binary argument to what was there already:

"r.rterm.option": [
  "--r-binary='C:\\Program Files\\R\\R-4.1.1\\bin\\R.exe'"
  "--no-save",
  "--no-restore",
  "radian"
]

However, I then get the following error in the terminal (screenshotted before it disappears):

image

In addition, I get the following message in a pop-up dialogue box on the bottom right:

image

To note, I can run R 4.1.1 in the VS Code terminal by running the following command in a PowerShell terminal in VS Code:

radian.exe --r-binary='C:/Program Files/R/R-4.1.1/bin/R.exe'

I am on Windows 11 running VS Code version 1.63.2, with vscode-R version 2.3.6.

MiguelRodo commented 2 years ago

I see that I had a syntax error above, based on this issue.

The argument to --r-binary should not have been quoted, as follows:

--r-binary=C:\\Program Files\\R\\R-4.1.1\\bin\\R.exe