I'm encountering an unusual behavior when using the debug
function in RStudio. I've defined a function and used debugSource
to source the script, but the debugging experience is not as expected.
Here's what I've done:
- Defined the function:
test <- function(x) {
browser()
y <- x^2
return(y)
}
-
Sourced the script:
debugSource("~/1.R")
-
Called the function:
test(1)
Expected behavior:
- I expected to enter a graphical debugging mode within the RStudio IDE.
- I should be able to use buttons like "Step" and "Continue" to control the debugging process.
- The "Environment" pane should display the values of variables in the current environment.
- I've attached an image showing the expected behavior, which I've observed on a different server:
Actual behavior:
- I'm entering a command-line debugging mode (Browse[1]>).
- The debugging menu options like "Execute next line" are grayed out (see attached image).
- The graphical debugging interface is not appearing.
What I've tried:
- Checked RStudio's global options for debugging settings
- Restarted RStudio
- Ensured the function is defined correctly and called appropriately
- Tried setting breakpoints directly
System Information:
- RStudio Version: RStudio Server 2023.09.1 Build 494
- OS Version: Ubuntu 22.04.4
- R Version: 4.4.0