-
-
Notifications
You must be signed in to change notification settings - Fork 877
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
line information for errors with inline chunks is incorrect #2387
Comments
Interestingly, the error line appears to be correct if there is a real chunk used before the inline chunk, e.g. ---
title: "Title"
format: html
---
This is some text.
```{r}
#| label: hello-world
print(1 + 1)
```
This is a line with an inline chunk, which errors. `r print(ouch)`
This is some more text. which gives > knitr::knit("example.Rmd")
processing file: example.Rmd
Warning: Duplicated chunk option(s) 'label' in both chunk header and pipe comments of the chunk 'hello-world'.
|........................................................| 100% Error:
! object 'ouch' not found
Backtrace:
1. base::print(ouch)
Quitting from lines 13-15 (example.Rmd) although then I see the strange spurious warning regarding a duplicated label? |
… consist of a single chunk, in which case the error location would not be printed
I think this is doable, and I'll do it. Actually I have already done it in litedown: ---
title: "Title"
format: html
---
This is some text.
This is a line with an inline chunk, which errors. `{r} print(ouch)`
This is some more text. > litedown::fuse('test.Rmd')
Error in eval(expr, fuse_env()) : object 'ouch' not found
Quitting from test.Rmd#8:53-8:67 The line/column numbers of the inline code will be printed (and in RStudio, users can click on the message to go to the exact location of the inline code).
Currently it is, but I agree it will look better if the error message starts on a new line.
That's a bug. I just fixed it. Thanks! |
…the error message can be displayed on a new line (#2387)
All done.
|
Awesome -- thanks @yihui! |
Consider a file with the contents:
If I knit this document with
knitr::knit("example.Rmd")
, I see:The lines for the error printed, "Quitting from lines 2-10 (example.Rmd)", are rather non-specific. Would it be possible to better report the line where this error occurred?
Also, as an aside: is it expected that the "Error:" printout here is placed on the same line as the progress bar?
By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: