3

The following app (reproducible example) works perfectly when deployed locally, but not when hosted on shinyapps.io. My understanding is that the quarto::quarto_render() call should have permission to write a file on shinyapps.io (it wouldn't be persistent from instance to instance, but that's fine). Does shinyapps.io not support quarto rendering? If not, does it support RMarkdown and would this code be expected to work with the appropriate conversions?

app.R:

library(shiny)
library(quarto)

ui <- fluidPage(

    titlePanel("Reproducable Example"),

    sidebarLayout(
      sidebarPanel(
        textInput(inputId = "user.name", label = "User name:"),
        br(),
        downloadButton(outputId = "report", label = "Generate Report:")
      ),
      mainPanel(
        
      )
    )
)


server <- function(input, output) {
  output$report <- downloadHandler(
    filename = "Reprod_ex.html",
    content = function(file) {
      
      quarto::quarto_render("myquarto.qmd", 
                            execute_params = list(username = input$user.name))
      
      file.copy("qmd_output.html", file)
      
    }
  )
}

# Run the application 
shinyApp(ui = ui, server = server)

myquarto.qmd:

---
format:
  html: 
    toc: false
    anchor-sections: false
    fig-cap-location: bottom
    tbl-cap-location: top
    number-sections: false
    smooth-scroll: true
    self-contained: true
    css: my-style.css
    output-file: "qmd_output.html"
params:
  username: NA
---

# Heading

My name is `r params$username`.

2 Answers2

2

quarto package itself does not include quarto binaries and currently quarto is not available at shinyapps.io, there's also an open issue on this - https://github.com/rstudio/shinyapps-package-dependencies/issues/332

Though RMarkdown works fine there, at least with that sample qmd and with few changes in content function:

    content = function(file) {
      rmarkdown::render("myquarto.qmd", params = list(username = input$user.name))
      file.copy("myquarto.html", file)
    }

To get some insights about quarto you can call quarto::quarto_path() and quarto::quarto_version() :

library(shiny)
library(quarto)

ui <- fillPage(
      verbatimTextOutput(outputId = "quarto")
)

server <- function(input, output) {
  output$quarto <- renderText({
    paste0("quarto::quarto_path(): ",quarto::quarto_path(),"\n",
           "quarto::quarto_version(): ", quarto::quarto_version()
           )
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

On a local Windows / RStudio installation this renders as:

quarto::quarto_path(): C:\PROGRA~1\RStudio\RESOUR~1\app\bin\quarto\bin\quarto.exe
quarto::quarto_version(): 1.2.269

When deployed to shinyapps.io :

An error has occurred. Check your logs or contact the app author for clarification.

shinyapps.io logs:

2023-01-27T15:34:47.308135+00:00 shinyapps[8147981]: Listening on http://127.0.0.1:39585
2023-01-27T15:34:49.804410+00:00 shinyapps[8147981]: Warning: Error in find_quarto: Unable to find quarto command line tools.
2023-01-27T15:34:49.816843+00:00 shinyapps[8147981]:   115: stop
2023-01-27T15:34:49.816876+00:00 shinyapps[8147981]:   114: find_quarto
2023-01-27T15:34:49.816881+00:00 shinyapps[8147981]:   113: quarto::quarto_version
2023-01-27T15:34:49.816889+00:00 shinyapps[8147981]:   111: renderText [/srv/connect/apps/quarto_test/app.R#10]

margusl
  • 7,804
  • 2
  • 16
  • 20
2

Quarto has been added to shinyapps.io. If you redeploy your application it will be added to your path.

Sam Perman
  • 21
  • 1