I'm trying to generate a report from a Shiny app using Quarto (see the code at the end of this post). I used the example provided in Chapter 9 Uploads and downloads | Mastering Shiny.
I'm getting the following error which I guess indicates that Shiny doesn't find Quarto:
Listening on http://127.0.0.1:13638
Avis : Error in : ! in callr subprocess.
Caused by error in `quarto::quarto_render(input, output_file = output, execute_params = params, …`:
! ✖ Error running quarto cli.
Caused by error:
! System command 'quarto.exe' failed
3: runApp
2: print.shiny.appobj
1: <Anonymous>
Quarto is properly installed on my machine though and I can render the document outside Shiny without any issue. Any idea how to fix this?
render_report <- function(input, output, params) {
quarto::quarto_render(
input,
output_file = output,
execute_params = params,
)
}
.lines <- paste(
"---",
"params:",
" text: NA",
"---",
"```{r}",
"params$text",
"```",
sep = "\n"
)
ui <- fluidPage(
textInput("text", "Write something", value = "blah blah"),
downloadButton("report", "Generate report")
)
server <- function(input, output) {
output$report <- downloadHandler(
filename = "report.html",
content = function(file) {
report_path <- withr::local_tempfile(
lines = .lines,
fileext = ".qmd"
)
callr::r(
render_report,
list(input = report_path, output = file, params = list(
text = input$text
))
)
}
)
}
shinyApp(ui, server)