Mac RStudio [Version 1.4.1106] debugger still not working and showing "Debug location is approximate because the source is not available"
Asked Answered
M

0

2

Problem is that in RStudio when I set a breakpoint to debug the code then the debugger is not stepping into my functions properly. Rather it takes me to some unknown lands and gives the warning message "Debug location is approximate because the source is not available".

I can see similar stack overflow questions in past raising this Rstudio issue. I can also see the issue being raised and closed on Github but I am still facing this issue in the latest version. Can someone suggest a fix or workaround?

EDIT:

Here is a step by step description of the problem:

  1. I have a project with various classes and functions distributed across many files and folders.

  2. I wanted to follow the function calls from the top script. To do this I set a breakpoint in the top function. Then I sourced the script.

  3. The debugger successfully stoped at the breakpoint. However, when I press "Step into the current function call" button, the debugger is taking me to some unknown code in the R language along with the error message that I mentioned. Looking at the code, it appears that the debugger is taking me to underlying R functions.

System

platform       x86_64-apple-darwin17.0     
arch           x86_64                      
os             darwin17.0                  
system         x86_64, darwin17.0          
status                                     
major          4                           
minor          0.5                         
year           2021                        
month          03                          
day            31                          
svn rev        80133                       
language       R                           
version.string R version 4.0.5 (2021-03-31)
nickname       Shake and Throw  

Apparantely it steps in to some random looking code and stops there, for example sometimes it stops here:

function (expr, msg) 
{
  on <- tracingState(FALSE)
  if (on) {
    on.exit(tracingState(TRUE))
    if (!missing(msg)) {
      call <- deparse(sys.call(sys.parent(1L)))
      if (length(call) > 1L) 
        call <- paste(call[[1L]], "....")
      cat("Tracing", call, msg, "\n")
    }
    exprObj <- substitute(expr)
    eval.parent(exprObj)
  }
  NULL
}
Maurey answered 14/5, 2021 at 1:32 Comment(5)
Have you saved your script to a file? Are you using the "run" button to run the script? It's a bit unclear exactly what is happening. Can you provide a reproducible example?Multiphase
Kindly check the edits in the above post.Maurey
What happens if you put a browser() call where the break point should be?Shult
@RomanLuštrik Thanks for the tip. Code actually stops at the browser() function, though now I have to manually add and delete browser() calls to debug the code. Better than not being able to debug at all.Maurey
That's still the way I debug all my code. :shrug:Shult

© 2022 - 2024 — McMap. All rights reserved.