Repository navigation
Closed
Description
System details
RStudio Edition : <!-- Desktop or Server --> Desktop
RStudio Version : 2025.09.0+387
OS Version : macOS Tahoe 26.0, aarch64, darwin20
R Version : R version 4.5.1 (2025-06-13)
version R version 4.5.1 (2025-06-13)
os macOS Tahoe 26.0
system aarch64, darwin20
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz Europe/Berlin
date 2025-09-27
rstudio 2025.09.0+387 Cucumberleaf Sunflower (desktop)
pandoc 2.9.2 @ /usr/local/bin/pandoc
quarto 1.7.33 @ /usr/local/bin/quarto
Steps to reproduce the problem
- Save the below code lines in a script outside of an R package project
- Set editor breakpoint in S7 method
- Save and source the file
- Run the lines inside the
if (FALSE)block. It's in the if block to avoid auto run of the code when the file is sourced.
S7::method(mean, S7::new_class("s7mean")) <- function(x, ...){
print("This is my S7 method")
}
if (FALSE){
x <- 1:4
mean(x)
class(x) <- "s7mean"
mean(x)
}Describe the problem in detail
Before Sourcing
Here is how the IDE displays the breakpoint inside the S7 method before sourcing. This looks fine, it tells me to source the file.
After Sourcing
Here is the IDE after I clicked "source". The breakpoint is gone and it's unclear whether it is set or not.
Additionally I see the warning
Breakpoints can only be set inside the body of a function.
which suggests that RStudio doesn't recognize the S7 method as function.
Running the code inside the if block results in
x <- 1:4
mean(x)
#> [1] 2.5
class(x) <- "s7mean"
mean(x)
#> [1] "This is my S7 method"So the breakpoint wasn't set and the only way for me to solve this is to use browser().
Describe the behavior you expected
I am looking to set editor breakpoints inside S7 methods.
- I have read the guide for submitting good bug reports.
- I have installed the latest version of RStudio, and confirmed that the issue still persists.
- If I am reporting an RStudio crash, I have included a diagnostics report.
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
Activity
gtritchie commentedon Sep 29, 2025
I repro'd this in various releases, so this isn't a recent change in behaviour.
kevinushey commentedon Dec 8, 2025
I spent a bit of time investigating today, and the issue mostly comes down to RStudio not understanding how to resolve the method definition from the code used to define the S7 method.
We'll need to explore the code here:
rstudio/src/cpp/session/modules/SessionBreakpoints.R
Lines 347 to 357 in 70c3366
and inspect the 'functionName' for things like
method(<generic>, <name>), and figure out how to resolve the actual defined function from that call.It's a little tricky for us as the code used to retrieve a method, and the code used to define a method, aren't necessarily congruent (re: RConsortium/S7#568).
ronblum commentedon Mar 10, 2026
Verified using the original example in RStudio Desktop Pro 2026.04.0-daily+364.pro3 on Windows 11.
port debugger BRAT tests (4 of 8) to Playwright (#17710)