Skip to content

Julia code chunks with errors cause R Markdown/Quarto rendering to fail even with error=TRUE when rendering via knitr #249

Open
@paciorek

Description

I reported the problem as this issue to knitr. In a comment in that issue, @cderv identified the problem as occurring upstream (i.e., here) and asked that I post it here and indicated he could contribute.

Here is the issue:

In an R Markdown or qmd file, one can use error=TRUE with an R code chunk (or the Quarto style #| error: true), but rendering fails with a Julia code chunk:

---
title: test
engine: knitr
---

```{julia, error=TRUE}
y
```

Here's the error (same thing if I do knit2html("test.qmd").

> rmarkdown::render("test.qmd")


processing file: test.qmd
  |....................................................| 100% [unnamed-chunk-1]Error:
! Error happens in Julia.
UndefVarError: `y` not defined
Stacktrace:
 [1] top-level scope
   @ :0
 [2] eval(m::Module, e::Any)
   @ Core ./boot.jl:385
 [3] macro expansion
   @ /system/linux/lib/R-22.04/4.4.0/x86_64/site-library/JuliaCall/julia/RmdStd.jl:15 [inlined]
 [4] top-level scope
   @ ./none:14
 [5] eval
   @ ./boot.jl:385 [inlined]
 [6] eval_string(x::String)
   @ Main.JuliaCall /system/linux/lib/R-22.04/4.4.0/x86_64/site-library/JuliaCall/julia/setup.jl:203
 [7] docall(call1::Ptr{Nothing})
   @ Main.JuliaCall /system/linux/lib/R-22.04/4.4.0/x86_64/site-library/JuliaCall/julia/setup.jl:176
Backtrace:
  1. rmarkdown::render("test.qmd")
  2. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  3. knitr:::process_file(text, output)
  6. knitr:::process_group(group)
  7. knitr:::call_block(x)
     ...
 13. JuliaCall:::stdout_capture_command(buffer)
 14. base::tryCatch(...)
 15. base (local) tryCatchList(expr, classes, parentenv, handlers)
 16. base (local) tryCatchOne(...)
 17. value[[3L]](cond)

Quitting from lines 7-8 [unnamed-chunk-1] (test.qmd)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions