JuliaInterop / JuliaInterop/JuliaCall

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

Open
#249 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
287
Forks
43
PR merge metrics
No merged PRs in 30d

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with rmarkdown::render("test.qmd") or knit2html("test.qmd") using the shown Julia chunk. Start at JuliaCall:::stdout_capture_command and the referenced JuliaCall/julia/RmdStd.jl path, then trace how the Julia error reaches knitr. Done means rendering completes when error=TRUE is set for the Julia chunk.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia, r
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.