Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected Closing Parentheses and Braces When Executing Code Chunks in R #1390

Open
brianmsm opened this issue Jul 2, 2023 · 9 comments
Open
Labels

Comments

@brianmsm
Copy link

brianmsm commented Jul 2, 2023

Describe the bug
When executing certain chunks of R code using VSCode with the R extension and Radian, I sometimes observe additional closing parentheses or braces being sent to the console, which were not present in the original code. This issue seems to occur after a small delay.

To Reproduce
This issue occurs sporadically and I have been unable to identify a consistent pattern. However, I've noticed that it happens frequently when I run the following chunks of R code multiple times:

data_test <- reduce(rep(list(mtcars), 2), bind_rows)

Can you fix this issue by yourself? (We appreciate the help)

No

(If applicable) Please attach setting.json

{
    "[r]": {
        "editor.defaultFormatter": "REditorSupport.r",
        "editor.formatOnSave": false,
        "editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?"
    },
    "[rmd]": {
        "editor.defaultFormatter": "REditorSupport.r",
        "editor.formatOnSave": false
    },
    "r.rmarkdown.knit.openOutputFile": true,
    "r.rmarkdown.codeLensCommands": [
        "r.runCurrentChunk",
        "r.runAboveChunks",
        "r.runBelowChunks"
    ],
    "r.source.encoding": "UTF-8",
    "r.source.focus": "editor",
    "r.alwaysUseActiveTerminal": false,
    "r.sessionWatcher": true,
    "r.rtermSendDelay": 8,
    "r.plot.useHttpgd": true,
    "r.lsp.debug": true,
    "r.rterm.windows": "C:\\Users\\brian\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\radian.exe",
    "r.liveShare.defaults.commandForward": true,
    "r.rterm.linux": "/usr/bin/radian",
    "r.liveShare.defaults.shareBrowser": true,
    "r.bracketedPaste": true,
    "r.session.levelOfObjectDetail": "Normal"
}

Expected behavior
I expect the code to be sent to the console as it is, without any additional characters.

Screenshots
Animation

Environment (please complete the following information):

  • OS: Windows 11
  • R Version: 4.3.0
  • VSCode Version: 1.79.2
  • Radian Version: 0.6.4

Additional context
I noticed that when I format the code differently, the problem does not occur. For instance, the following code does not produce the issue:

data_test <- reduce(
  rep(list(mtcars), 2),
  bind_rows
)

In addition, it also does not play when instead of using bind_rows, I use rbind :

data_test <- reduce(rep(list(mtcars), 2), rbind)
@brianmsm brianmsm added the bug label Jul 2, 2023
@lijiaqi-github
Copy link

lijiaqi-github commented Jul 7, 2023

I have been aware of this issue for the past two years and have been searching for a solution, as having this problem renders Radian completely unusable. However, I have been unable to find a solution thus far.

Based on the results of my attempts, I have found that this problem is prone to occur when executing lines of code that contain numerous parentheses(for reference only).

I made an example, a formula I scribbled. When I run it slowly, there are no errors. However, when I run it continuously, unexpected brackets appear.

2023-07-07.174752.mp4

When I run a shortened version of the formula, even with a quick click, it runs without errors.

2023-07-07.175159.mp4

Similar error donot occur in R terminal (not radian).

2023-07-07.180113.mp4

@brianmsm
Copy link
Author

Well, this seems to be an old and already known problem: #419, #820, randy3k/radian#303, randy3k/radian#277, randy3k/radian#230 . And it is only happening on windows, because Bracketed paste mode is not supported.

The first one associated with the addition of parentheses or braces when sending a code to the console. It seems as if there is a brief desynchronization when sending the code to the console, and radian tries to close parenthesis before seeing that it was already closed. This can be easily fixed by disabling auto-completion in the .Rprofile or .radian_profile file.

options(radian.auto_match = FALSE)
  1. The second is a bit more problematic and is apparently occurring when the code block is very large, or when a chunk is executed that has several code blocks and these have to be sent all at once to the console. There is a very temporary workaround proposed here that reduces the number of times the problem occurs, although it still happens: Send code to terminal by Ctrl + ENTER but don't run #820 (comment)

@lijiaqi-github
Copy link

I remembered that someone told me this before, but I don't know where ".radian_profile" is. Can you tell me how to find ".radian_profile", thanks.

@D3SL
Copy link

D3SL commented Jul 20, 2023

@brianmsm There's also, in my experience at least, two new showstopping bugs that started recently: Radian eventually stops printing any output at all, and prior to that it will begin freezing for tens of seconds or more at a time in the middle of executing even a single line of code.

What's interesting to me is all of these feel like regressions. When I first began using VSCode-R with Radian the only issue I had consistently was the buildup of background processes from the language server, and only something as huge as an entire shiny app would fail to auto-execute on ctrl+enter. Both VSCode-R and Radian have steadily gotten less reliable and performant with time.

For example starting an R session with the built in command palette function on an SSH remote is unusable, but calling R at the terminal to create an R session works great.

@benz0li
Copy link
Contributor

benz0li commented Jul 21, 2023

There's also, in my experience at least, two new showstopping bugs that started recently: Radian eventually stops printing any output at all, and prior to that it will begin freezing for tens of seconds or more at a time in the middle of executing even a single line of code.

@D3SL Can you reproduce this on my reference deployment at https://demo.jupyter.b-data.ch?

  • OS: Debian 12
  • Code Version: 1.79.2
  • Radian Version: 0.6.6
    • r executable: /usr/local/lib/R/bin/R
    • r version: 4.3.1
    • python executable: /usr/local/bin/python
    • python version: 3.11.4

ℹ️ These seem to be Windows specific issues.

@nicholskl
Copy link

New to VSCode-R, and love the idea of it more than the experience at this point. These bugs - persisting even after trying solutions - make Radian completely unusable. Hard to believe these problems have persisted for years apparently.

@thedbcooper
Copy link

I am still having this issue using Windows 10. Radian is not usable in its current state for me.

@nicholskl
Copy link

Unbelievable that this hasn't been fixed or addressed.

@D3SL
Copy link

D3SL commented Feb 21, 2024

@nicholskl that's a bit over the line. First this is fundamentally a problem with Windows itself, and second VSCode-R is basically a two-man show run by Renkun-ken and Ikuyadeu. And they're fighting an uphill battle against the RStudio monopoly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants