Skip to content

Debugging internal R functions in RStudio does not go to source #18754

Description

@njtierney

Debugging internal functions in RStudio, inside a function, does not open up R source files to debug, instead printing them to the console

System details

RStudio Edition : Desktop
RStudio Version : 2026.08.2+200
OS Version      :  "macOS Tahoe 26.5.2"
R Version       :  R version 4.6.1 (2026-06-24)

Steps to reproduce the problem

debugonce(lm)

lm(bill_dep ~ ., data = penguins)
# works - opens up lm source code

fit_lm <- function(data){
    lm(bill_dep ~ ., data = data)
}

debugonce(fit_lm)
fit_lm(penguins)

# using `s` to step into `lm` here puts it in the console
# similarly, using `debugonce(lm)` once inside the context of `fit_lm()`
# does not open up the lm file

debugonce(lm)
fit_lm(penguins)
# this has the same effect as above - it puts the lm() code in the console

Describe the problem in detail

When I debug an internal function, like lm(), I can see the source code in Rstudio:

debugonce(lm)
lm(bill_dep ~ ., data = penguins)
Image

But then if I place that lm() code inside a function, when I go to step into lm() it puts the debugging information in the console:

fit_lm <- function(data){
    lm(bill_dep ~ ., data = data)
}

debugonce(fit_lm)
fit_lm(penguins)

# using `s` to step into `lm` here puts it in the console
Image Image

Describe the behavior you expected

When doing:

fit_lm <- function(data){
    lm(bill_dep ~ ., data = data)
}

debugonce(fit_lm)
fit_lm(penguins)

And stepping into lm() or even doing debugonce(lm) inside that function, I would expect it to take me to the lm source, and open up a panel like this:

Image
  • 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.

Thank you maintainers for making a product I know and love.

For what it is worth, I do not have these same issues in positron - however I prefer to use RStudio, especially for teaching.

Activity

  1. added theissue type on Sep 10, 2026
  2. njtierney commented on Sep 17, 2026

    @njtierney
    Author

    Thank you very much @kevinushey !

  3. kevinushey commented on Sep 17, 2026

    @kevinushey
    Collaborator

    Our pleasure; thanks for taking the time to report the issue!

  4. njtierney commented on Oct 19, 2026

    @njtierney
    Author

    Just wanted to say thank you for this again, @kevinushey - tried it now and it works great! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions