-
-
Notifications
You must be signed in to change notification settings - Fork 975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error line numbers are wrong #381
Comments
Thanks for this feedback. I think you are correct that debug-ability of Rmd isn't great, and I'm sure there are some simple things we can do (like the ones you suggest) to improve this. This will probably be a combination of IDE work and rmarkdown package work, and we hope to take this on soon. |
Wonderful. In the meanwhile, have you collected somewhere the reason why the line number for a bug reset to the first line a code chunk? I know it happens when I source, but it also happens without that sometimes (to be honest, I'm still trying to fix one particular error :-). |
I'm not sure whether error information more granular than that is available On Mon, Feb 23, 2015 at 12:39 AM, Ruben C. Arslan [email protected]
|
Well usually the line number is right, so I think it's mostly about picking the most appropriate line from the trace, I've been able to identify two exceptions:
I found this issue in evaluate, I think it is about some of the same stuff: r-lib/evaluate#37 |
@rubenarslan For debugging, you can compile the document in an interactive R session instead of clicking the button in RStudio, since it is not easy to debug in a non-interactive R session. Take the following minimal file test.Rmd as an example:
When you compile it via
If you show traceback, you see
First, knitr tells you the error came from lines 2-8, and you can find that code chunk; then there are line numbers like You can click |
@yihui thanks, I know I can do that, but it used to be that it didn't need to do so as often (with knitr, as opposed to rmarkdown, but maybe I'm just making different mistakes these days). My reports often take hours to generate, so I love the fact that Rstudio quickly spawns them in another process. Are there plans to make Rstudio able to spawn/manage more than one extra process? If often have multiple reports to re-generate once I fixed a bug in cleaning scripts etc. and mostly I three of four cores are idle. |
Is there any update on debugging with |
Would also be interested if there's any documented workflows that people know of that do testing (like devtools/R CMD check for packages) for Rmd files? |
@Deleetdk No update. Sorry. @rubenarslan I don't have a better suggestion other than calling For your last question, you may see ropensci/unconf17#38 (I forgot the name of the package that they developed and you can ask them).
I'm closing this issue because I feel there isn't much we can do in the rmarkdown package to improve debug-ability. |
@yihui my suggestion would have been a fresh interactive session, not
the current one with all its state/loaded packages. Just so that after it
fails or emits too many warnings to be shown, I can run warnings() or
traceback()
Are the error line numbers in the report still wrong sometimes? I haven't
checked this in a while.
|
One particularly annoying thing with debugging in R notebooks is that when you are inside |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Sorry if this rather belongs in Rstudio.
Debugging Rmds was easier with knitr, because it sent you to the right line number when an error occurred. Now the default view is the "Issues" view in Rstudio. Not only is this view a bit cramped, it contains superfluous information (like the trace "Calls: ... withCallingHandlers -> withVisible -> eval -> eval -> plot" – everything from Anonymous to plot is just related to knitr internals, I don't care about it and it confuses our B.Sc.s).
You cannot copy the entries in the Issues view.
The output view is more useful, but it only says
Quitting from lines 19-21 (test.Rmd)
, ie. it gives you only an approximate line number.The line number in "Issues" is precise, but it can be completely off. One instance where I could pinpoint it: if I source an R script inside a chunk, all errors after the source statements will be pinned to the top of the chunk.
Here's a reproducible script:
I hope bugs relating to this can be fixed and that debugging Rmds becomes easier in general.
I've had some fairly difficult to debug problems recently where these changes made them very tough to crack.
Usually I simply execute a file with Command-Shift-S in a fresh session so that I can debug in the session.
This is not my favourite way though, because this way I don't benefit from the cache, and some of my Rmd files take hours to execute.
I would love to be able to pick up inside the session when rmarkdown errors out, I don't know if that's possible though.
The text was updated successfully, but these errors were encountered: