Hillary Sanders
Hillary Sanders

Reputation: 6047

RStudio enters debug mode for every function error - how can I stop it?

I've been using RStudio for years, and this has never happened to me before. For some reason, every time a function throws an error, RStudio goes into debug mode (I don't want it to). Even after using undebug() on a single function.

> undebug(http.get)
Warning message:
In undebug(fun) : argument is not being debugged
> x = http.get(country = 'KE')

http --timeout=60 get "http://[email protected]/observation?country=KE" > freshobs.json </dev/null
Error in fromJSON(file = "freshobs.json") : unexpected character 'O'

Error in el[["product_name"]] : subscript out of bounds
Called from: grepl(el[["product_name"]], pattern = "json:", fixed = T)
Browse[1]> Q

Any function I use that breaks causes debug mode to start - which is pretty annoying because it opens up a source viewer and takes you away from your code. Anybody know how to stop this functionality? This happens when the 'Use debug mode only when my code contains errors' check box in Preferences is and is not checked.

Thanks!

Upvotes: 44

Views: 11214

Answers (5)

mdjupin
mdjupin

Reputation: 1

I had the same issue in RStudio Cloud. It was solved by choosing a different version of R. I was using R3.6.0 and changed it to R3.5.3 (the option in in the upper right corner). It refreshed the console and the debugging stopped. And then R3.6.0 was again fine. Cheers.

Upvotes: 0

Andre Elrico
Andre Elrico

Reputation: 11500

Nothing worked for me: I had a function that when I run kept on debugging.

The solution for me was (with caution pls): Debug (menü) -> clear All Breakpoints ...

Upvotes: 1

imanuelcostigan
imanuelcostigan

Reputation: 3539

I reset my RStudio Desktop preferences and the issue went away.

Note that the options()$error return value after this reset is:

(function () 
{
    .rs.recordTraceback(TRUE, 5, .rs.enqueueError)
})()

The value before this change was per comment above

Upvotes: 0

Maehler
Maehler

Reputation: 6331

I tried fixing this issue by putting options(error = NULL) in my .Rprofile, but this did not work.

What did work was to go to the "Debug" -> "On Error" menu and select "Message only". This effectively is the same as setting options(error = NULL), but it is persistent across restarts.

RStudio menu

Upvotes: 63

Hillary Sanders
Hillary Sanders

Reputation: 6047

Well, I think I sort of fixed it. No idea how this happened, but in Rstudio, running

> options()$error # returned:
 (function () 
{
    .rs.breakOnError(FALSE)
})()

Where as in the same thing returned NULL when running R from terminal. --> I ran:

options(error=NULL)

That fixes the problem - but only temporarily. When I quit and restart Rstudio, the code needs to be run again. Will update when I find a way to change the default... Cheers.

Upvotes: 2

Related Questions