Reputation: 2886
I am trying to set up R to work with Visual Studio code.
When i execute a line with the keys CTRL
+ENTER
I get the error "win32 can't use R".
I am following the advice laid out in this medium post where i have managed to install all the extensions but am unsure where to apply point "4. Finally add these lines in the settings.json of your editor"
I have seen the this post which describes (I think) how to update the settings.JSON but to be honest im not sure where and if this is the correct place to add the lines in the original post.
The JSON file on my PC looks like the below
{
"[json]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace",
"gitlens.codeLens.scopes": [
"document"
]
}
}
Could someone point me in the right direction
Thanks
Upvotes: 22
Views: 55912
Reputation: 744
When I had this error, I did the following with Win10Pro (20H2) and VSC 1.53.0-insider
C:\Program Files\R\R-3.6.2\bin\x64\R.exe
Extensions > R
R > Rpath: Windows
Rterm.exe
as well.Upvotes: 50
Reputation: 881
Even changing both settings in the way @Dr_Be mentions, I still couldn't run R code. This is the error I got:
Cannot find R client at "C:\Program Files\R\R-4.2.2\bin\x64\Rterm.exe". Please check r.rterm setting.
The reason for these errors was that I was pasting the filepath to both R.exe and Rterm.exe (as the previous answers point out) with quotes at the beginning and ending of the filepath, as you would when using CLI. Just paste them without the quotes and it should work.
Upvotes: 3
Reputation: 680
File -> Preferences -> Settings
Rpath: C:\Users\xxxxx\AppData\Local\Programs\R\R-4.2.1\bin\R.exe
Rterm: C:\Users\xxxxx\AppData\Local\Programs\R\R-4.2.1\bin\R.exe
Then install at least one library using RGui (which is outside of VScode).
Restart VScode will then it will recognize the R library path.
Upvotes: 9
Reputation: 687
My fix to resolve 'win32 can't use R' in VSCode was to uninstall R and install without 32-bit at all.
When installing R, there is the option to install 32-bit and 64-bit. I de-selected 32-bit, and now it works fine.
As a noob, my first install included both 32-bit AND 64-bit (although it was installed into the 64-bit Program Files)...
Upvotes: 0
Reputation: 252
Just to point out that @Andrew was correct with his last comment to his answer. At least on my Windows installation I had to put both paths in order to get rid of the "win32 can't use R" error, i.e. the path to R.exe shown in the screenshot plus the path to Rterm.exe at the entry R > Rterm: Windows
. Without the second entry the error persisted in my case.
Upvotes: 10