vscode-R
vscode-R copied to clipboard
R Terminal doesn't show up
- VSCode Version: 1.53.2
- VSCode-R Version: 1.6.4
- OS Version: Windows 10 Education, 20H2
Steps to Reproduce:
- Install R, VSCode-R extension, VSCode R LSP Client, etc.
- Update settings to have r.rterm.windows and r.rpath.windows point to radian and R, respectively
- Start an R file and send code to terminal
- Only the Powershell terminal is shown
(If related)setting.json
"r.alwaysUseActiveTerminal": true,
"r.bracketedPaste": true,
"r.rterm.windows": "C:\\Users\\Jason\\AppData\\Local\\Programs\\Python\\Python39\\Scripts\\radian.exe",
"r.rpath.windows": "C:\\Program Files\\R\\R-4.0.4\\bin\\R.exe",
"r.rterm.option": [
"--no-save",
"--no-restore",
"--r-binary=C:\\Program Files\\R\\R-4.0.4\\bin\\R.exe"
],
"r.sessionWatcher": true
I've tried searching for ways to fix this, but everything I've found just points to specifying the same settings I have set above. Any help would be greatly appreciated.
One more detail: When I look at the output for R Language Server, I see the following:
R Language Server (5636) started Error: '\U' used without hex digits in character string starting "'C:\U"
Execution halted
R Language Server (5636) exited with exit code 1
Since you have "r.alwaysUseActiveTerminal": true
set, sending code to the terminal will not automatically start R. Try starting R in the terminal first. Or, if you would prefer to have R start automatically, remove the setting "r.alwaysUseActiveTerminal": true
.
Error: '\U' used without hex digits in character string starting "'C:\U"
It looks like VS Code is having trouble with "r.rterm.windows": "C:\\Users
. Try changing all the \\
to /
. If that doesn't work, try changing them all to \
.
Looks like I'm heading in the right direction. The RLS output now shows "R Language Server (undefined) started". However, I'm still not able to run anything in the terminal. I tried starting R first, but the terminal in VS Code stays set to Powershell. Here's how my settings looks after changes (I've also tried the other change you suggested):
"r.rpath.windows": "C:/Program Files/R/R-4.0.4/bin/R.exe",
"r.rterm.windows": "C:/Users/Jason/AppData/Local/Programs/Python/Python39/Scripts/radian.exe"
Good to hear there's some progress on the RLS side.
I tried starting R first, but the terminal in VS Code stays set to Powershell.
How are you starting R/radian?
Could you post a screenshot of the terminal after you've tried starting R/radian?
I just start R by running the R.exe. Here's a screen shot with the R terminal in the foreground, and VS Code with the PowerShell terminal in the background.
Thank you for the screenshot. You need to start R in the PowerShell terminal, not in a separate window.
Lol, I see now. When I run Python programs, it seems like the Python terminal automatically starts up. Is there not a way to do that with this extension?
If you would prefer to have R start automatically, remove the setting "r.alwaysUseActiveTerminal": true
. Then it will start a new R console when you run R code, if there isn't an R console already.
Thanks, I have done that to this point. These are the only two settings I currently have for R:
"r.rpath.windows": "C:/Program Files/R/R-4.0.4/bin/R.exe", "r.rterm.windows": "C:/Users/Jason/AppData/Local/Programs/Python/Python39/Scripts/radian.exe"
Oh! That's strange then. So when you run R code, it just sends the line of code to the PowerShell terminal as shown in your screenshot?
What command are you using to run the R code? I wonder if it's a command from a different extension.
What happens if you use the command R: Run Selection/Line
?
@jichavez3 Any update on this?
@jichavez3 It's been a month without an update, and I think the problem is probably due to using a non-vscode-R command rather than a bug in vscode-R, so I'm going to close this issue. But if you're still encountering the problem feel free to post with the answers to my questions above and I'll be happy to help further.
So sorry for the delayed response. I'm completing a Masters degree and switched over to R Studio to get assignments completed and ignored this thread. Here's the answers to your questions:
Oh! That's strange then. So when you run R code, it just sends the line of code to the PowerShell terminal as shown in your screenshot? That's correct, it wouldn't move past the PowerShell. I recently installed Kite for work I'm doing in Python, and now when I send the code to terminal, it just restarts the PowerShell terminal.
What command are you using to run the R code? I wonder if it's a command from a different extension. This happens when I simply try to load the tidyverse library (library(tidyverse)).
What happens if you use the command R: Run Selection/Line?
It used to give the error shown in my screenshot, now it looks to be restarting the PowerShell. It flashes an error stating "Failed to create process", but it's too quick to for me to grab a screenshot.
Hi @jichavez3, thank you for the update. No worries - your degree is definitely higher priority than this issue :)
I recently installed Kite for work I'm doing in Python, and now when I send the code to terminal, it just restarts the PowerShell terminal.
So the problem happens with Python too? It feels like there's possibly a problem with PowerShell.
What happens if you use the command R: Create R Terminal
?
What happens if you start R in the PowerShell console, then use the command R: Run Selection/Line
?
What happens if you use cmd instead of PowerShell? You can set this in your settings.json
like this: "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe"
Sorry for the confusion. I meant to just point out that the behavior has changed for R since installing Kite in that I don't see the error I showed previously anymore (not positive that Kite caused the change, just that that's one of few changes I've made since we last spoke). Sorry again about the confusion, I can see how my wording was a bit misleading. With Python, there's an option to "Run selected line in Python terminal", and that works fine. If, however, I just do a ctrl+shift+enter, it doesn't automatically go to the Python terminal.
When I use the command R: Create R Terminal
I get the terminal temporarily flashing "Failed to create process", then the terminal goes away.
When I start R in the terminal then Run Selection/Line it works fine.
When I switch to cmd, if I run R: Run Selection/Line
then I get the same error as above "Failed to create process." If instead I do ctrl+shift+enter (which I thought mapped to the same function), I just get an error saying:
'library' is not recognized as an internal or external command, operable program or batch file.
Thank you for this info. My thought is that there's a problem with radian. Can you try copy-pasting the path to radian from your r.rterm.windows
setting into the terminal? My guess is that you'll get the 'Failed to start process' error.
Radian is a Python program (which wraps R) so if you're having problems with Python since installing Kite that may be the reason you're having problems with radian.
You might also want to check your keyboard shortcuts since it sounds like Ctrl+Shift+Enter is not bound to R: Run Selection/Line
.
Yep, I do get the failed to create process error when I try to launch radian from the terminal. I ended up uninstalling Kite both on my computer and in VS Code, and still get the error with radian.
Is the best bet here to remove radian from the r.rterm.windows
setting?
Okay, it does sound like the problem here is radian and/or Python. That's not something controlled by vscode-R. I haven't come across that particular error with radian so I'm afraid I can't really help with that.
Yes, for now I would recommend removing radian from the r.rterm.windows
. The vscode-R experience is better with radian but it does work with the standard R console.
Hi, I have a solution to this problem, seeing as I have had this error too.
The problem for me was in the .Rprofile file generated by the "languageserversetup" package for me, which I had installed by following the post https://www.r-bloggers.com/2020/03/setting-up-r-with-visual-studio-code-quickly-and-easily-with-the-languageserversetup-package/. The library address there had a single backslash which affected the startup of R.
Just change the / to // or \ as you want and the error is gone.
There is a warning, but I don't think that could be any major problem for execution in R, but it works. Below are my outputs after the fix.
Awesome! Thanks for the information. I'll try this solution out soon to see if it works. Thanks again!
The vscode-R experience is better with radian but it does work with the standard R console.
In the PowerShell terminal in VSCode I can easily switch it from PowerShell to Radian by simply typing radian
and hitting enter, and then the terminal instantly switches to Radian (rather than opening a new terminal). Same goes for the Command Prompt if I type cmd
into PowerShell or for Python if I type py
.
How can I do that with the standard R console? If I just type R
or R.exe
into PowerShell it doesn't work.
@seebruck This is probably because R and R.exe are not on your Windows Path. You will need to edit your Environment Variables to add their location to Path. Note that this is a Windows setting and not a VS Code setting.
This issue is stale because it has been open for 365 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.