what-they-forgot icon indicating copy to clipboard operation
what-they-forgot copied to clipboard

Mention debugonce()?

Open jennybc opened this issue 6 years ago • 8 comments

Maybe in the debug() section here:

https://whattheyforgot.org/debugging-r-code.html#debugging-others-code

jennybc avatar Feb 26 '19 18:02 jennybc

I have literally never used this myself (barely ever used debug() either for that matter), but sure ;)

jimhester avatar Feb 26 '19 21:02 jimhester

Hmmm, I have been using debugonce() lately 🤔. Context: debugging things in another package . For example, I used it when figuring out that devtools / remotes problem. I wanted to call devtools but drop into the debugger when I entered remotes:::combine_deps().

And I think I used when I was doing revdep checks (and PRs) for tibble v2.x. Once you figure out who's screaming, you do debugonce() on that, then rerun the test.

jennybc avatar Feb 26 '19 21:02 jennybc

What would your workflow be in those situations?

jennybc avatar Feb 26 '19 21:02 jennybc

Generally when I am that far into the weeds debugging something I am planning on fixing it and sending a PR, so generally I do the standard clone + load_all() + browser() thing.

But I can see how it would be useful and we probably should mention it.

jimhester avatar Feb 26 '19 21:02 jimhester

It's true that I was in the the source package at that point. So I think I did eventually use browser().

jennybc avatar Feb 26 '19 22:02 jennybc

Thinking about this more I guess I typically use options(error = recover) when there is something in another package where you could potentially use debugonce()

jimhester avatar Feb 27 '19 16:02 jimhester

I think an interesting axis on which to compare all of these is how ephemeral they are, i.e. what it feels like to turn the debugging approach ON and OFF. I suspect that influences what we are choosing in different situations.

jennybc avatar Feb 27 '19 17:02 jennybc

And also the affordances in our preferred working environment, e.g. RStudio vs. emacs/vim, whether you have the source package yet or not, etc.

jennybc avatar Feb 27 '19 17:02 jennybc