Skip to content

could not get shinylive to work with rig R installation #76

@antoinelucasfra

Description

@antoinelucasfra

issue encountered

There is an issue with how shinylive can not render shinylive app inside quarto document when R has been installed with rig.

Here is my mydoc.qmd document to render :

---
title: "test r-shinylive App in a Quarto document!"
format: html
embed-resources: true
engine: knitr
execute:
    engine: knitr
    rpath: "C:/Program Files/R/R-4.5.1"
filters:
  - shinylive
---


```{shinylive-r}
#| standalone: true
#| components: [editor, viewer]
#| viewerHeight: 650

library(shiny)
library(bslib)

ui <- page_sidebar(
  title = "Editable Shiny App in Quarto",
  sidebar = sidebar(
    sliderInput("bins", "Number of bins:", min = 5, max = 30, value = 10)
  ),
  plotOutput("distPlot")
)

server <- function(input, output) {
  output$distPlot <- renderPlot({
    x <- mtcars$mpg
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    hist(x, breaks = bins, col = "skyblue", border = "white",
         main = "Histogram of MPG", xlab = "Miles Per Gallon")
  })
}

shinyApp(ui = ui, server = server)
```

Here is the output when running quarto render mydoc.qmd :

(E) Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?
 Error:
 PandocError {}
Error running filter C:/Users/anlucas/AppData/Local/Programs/Quarto/share/filters/main.lua:
...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:40: Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?

stack traceback:
        ...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:40: in global 'throw_quarto_error'
        ...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:86: in global 'callRShinylive'
        ...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:113: in global 'callShinylive'
        ...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:286: in global 'ensureBaseSetup'
        ...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:315: in global 'ensureLanguageSetup'
        ...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:424: in function <...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:408>
        [C]: in ?
        [C]: in method 'walk'
        ...ta\Local\Programs\Quarto\share\pandoc\datadir\_utils.lua:607: in function '_utils.walk'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:572: in local 'checked_walk'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:627: in function 'run_emulated_filter'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1314: in local 'callback'
        [string "if pandoc.system.os == "mingw32" then..."]:778: in field 'withScriptFile'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1330: in upvalue 'run_emulated_filter_chain'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1368: in function <...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1365>
stack traceback:
        ...ta\Local\Programs\Quarto\share\pandoc\datadir\_utils.lua:607: in function '_utils.walk'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:572: in local 'checked_walk'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:627: in function 'run_emulated_filter'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1314: in local 'callback'
        [string "if pandoc.system.os == "mingw32" then..."]:778: in field 'withScriptFile'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1330: in upvalue 'run_emulated_filter_chain'
        ...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1368: in function <...cas/AppData/Local/Programs/Quarto/share/filters/main.lua:1365>
WARN: Error encountered when rendering files

configuration

It seems that my quarto check and shinylive package and extension are ok and up-to-date :

  • quarto check :
$ quarto check
Quarto 1.8.25
[>] Checking environment information...
      Quarto cache location: C:\Users\anlucas\AppData\Local\quarto
[>] Checking versions of quarto binary dependencies...
      Pandoc version 3.6.3: OK
      Dart Sass version 1.87.0: OK
      Deno version 2.3.1: OK
      Typst version 0.13.0: OK
[>] Checking versions of quarto dependencies......OK
[>] Checking Quarto installation......OK
      Version: 1.8.25
      Path: C:\Users\anlucas\AppData\Local\Programs\Quarto\bin
      CodePage: 1252

[>] Checking tools....................OK
      TinyTeX: v2025.10
      Chromium: 869685

[>] Checking LaTeX....................OK
      Using: TinyTex
      Path: C:\Users\anlucas\AppData\Roaming\TinyTeX\bin\windows\
      Version: 2025

[>] Checking Chrome Headless....................OK
      Using: Chrome found on system
      Path: C:\Program Files\Google\Chrome\Application\chrome.exe
      Source: Windows Registry

[>] Checking basic markdown render....OK

[>] Checking Python 3 installation....OK
      Version: 3.14.0
      Path: C:/Users/anlucas/AppData/Local/Programs/Python/Python314/python.exe
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python -m pip install jupyter

[>] Checking R installation...........OK
      Version: 4.5.1
      Path: C:/PROGRA~1/R/R-45~1.1
      LibPaths:
        - C:/Users/anlucas/OneDrive - Professional/Documents/0_workspace/bp-matrix-track/renv/library/windows/R-4.5/x86_64-w64-mingw32
        - C:/Users/anlucas/AppData/Local/R/cache/R/renv/sandbox/windows/R-4.5/x86_64-w64-mingw32/0eea1ca5
      knitr: 1.50
      rmarkdown: 2.30

[>] Checking Knitr engine render......OK
  • shinylive R pkg :
shinylive::assets_version()
[1] "0.9.1"`
  • different output from rig :
$ rig run Rscript -e "library(shinylive); packageVersion('shinylive')"
[1] '0.3.0'

potential diagnostic

It apppears due to the error msg extract :

(E) Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?
 Error:
 PandocError {}
Error running filter C:/Users/anlucas/AppData/Local/Programs/Quarto/share/filters/main.lua:
...rix-track\_extensions\quarto-ext\shinylive\shinylive.lua:40: Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?

that the Lua filter is calling Rscript directly instead of rig, might lead to some environment calling issues between rig, quarto and shinylive ?
Still investigating in the shinylive.lua script to find a workaround :

-- R specific method to call {r-shinylive}
-- @param args: list of string arguments to pass to r-shinylive
-- @param input: string to pipe into to r-shinylive
function callRShinylive(args, input)
  args = { "-e",
    "shinylive:::quarto_ext()",
    table.unpack(args) }

  -- Try calling `pandoc.pipe('Rscript', ...)` and if it fails, print a message
  -- about installing shinylive R package.
  local res
  
  local status, err = pcall(
    function()
      res = pandoc.pipe("Rscript", args, input)
    end
  )

  if not status then
    throw_quarto_error(
      "Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?",
      "Error running 'Rscript' command. Perhaps you need to install / update the 'shinylive' R package?\n",
      "Error:\n",
      err
    )
  end

  return res
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions