Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Up Visual Studio code to work with R - "win32 can't use R"

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

like image 609
John Smith Avatar asked Jan 21 '21 08:01

John Smith


People also ask

Does Vscode support R language?

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.


2 Answers

When I had this error, I did the following with Win10Pro (20H2) and VSC 1.53.0-insider

  1. Locate your R.exe location. Mine is at C:\Program Files\R\R-3.6.2\bin\x64\R.exe
  2. Open VSC, once loaded, press [CTRL]+',' to open your settings. In "Search Settings" type "R".
  3. In the left column under "Commonly Used" scroll down to Extensions > R
  4. In the settings for "R", scroll down to R > Rpath: Windows
  5. Enter the RPath determined in #1 above, then [CTRL]+'S' to save. Or when you close the "Settings" pane, I think it should save.
  6. Restart VSC and the error should go away.

enter image description here

like image 91
Andrew Avatar answered Nov 15 '22 06:11

Andrew


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.

like image 29
Dr_Be Avatar answered Nov 15 '22 05:11

Dr_Be