-
Notifications
You must be signed in to change notification settings - Fork 11
Cannot get shinylive to work in a rocker container #71
Copy link
Copy link
Open
Description
I am trying to render a quarto document with R shiny using the shinylive extension in a docker container. After some caching related errors, I got it to run without error, but it doesn't render properly.
docker run --platform=linux/amd64 --rm -u 1000:1000 -v ${PWD}:/home/rstudio/work shinylivetest quarto render index.qmd
Click for output
pandoc
to: html
output-file: index.html
standalone: true
embed-resources: false
section-divs: true
html-math-method: mathjax
wrap: none
default-image-extension: png
metadata
document-css: false
link-citations: true
date-format: long
lang: en
title: Shinylive
date: today
! '/tmp/quarto_cache_home/shinylive/shinylive-0.9.1' assets directory does not exist.
ℹ Downloading shinylive assets v0.9.1
Downloading 29% ■■■■■■■■■■ 2s
Downloading 36% ■■■■■■■■■■■■ 2s
Downloading 100% ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ 0s
✔ Downloading shinylive assets v0.9.1 [13.8s]
ℹ Unzipping shinylive assets to '/tmp/quarto_cache_home/shinylive'
✔ Unzipping shinylive assets to '/tmp/quarto_cache_home/shinylive' [3.4s]
! Failed to update system requirement mappings, will use cached mappings.
✔ Updated metadata database: 4.02 MB in 9 files.
ℹ Updating metadata database
✔ Updating metadata database ... done
! Failed to update system requirement mappings, will use cached mappings.
ℹ Loading metadata database
✔ Loading metadata database ... done
! Failed to update system requirement mappings, will use cached mappings.
! Failed to update system requirement mappings, will use cached mappings.
Output created: index.html
To reproduce
Create an index.qmd:
Click here
---
title: "Shinylive"
date: today
format:
html:
embed-resources: false
filters:
- shinylive
---
## App 1
```{shinylive-r}
#| eval: true
#| standalone: true
shinyApp(
ui=fluidPage(
sliderInput("value", label="Value", min=1, max=50, step=1, value=2),
textOutput("out")
),
server=function(input, output, session) {
output$out <- renderText(paste0("Squared: ",input$value^2))
}
)
```
## App 2
```{shinylive-r}
#| eval: true
#| standalone: true
#| viewerHeight: 450
# webr::install(c("ggplot2", "bslib", "htmltools"))
# install.packages(c("ggplot2", "bslib", "htmltools"))
library(htmltools)
library(bslib)
library(ggplot2)
pc <- prcomp(diamonds[,c("carat", "depth", "table", "price", "x", "y", "z")], center = TRUE, scale. = TRUE)
dfr <- cbind(diamonds,as.data.frame(pc$x))
ui <- page_sidebar(
sidebar = sidebar(
selectInput("x",
label = "X axis",
choices = c("PC1","PC2","PC3","PC4"),
selected = "PC1"
),
selectInput("y",
label = "Y axis",
choices = c("PC1","PC2","PC3","PC4"),
selected = "PC2"
),
selectInput("v",
label = "Color",
choices = c("cut", "color", "clarity"),
selected = "cut"
)
),
imageOutput("plot", height = "350px")
)
server <- function(input, output, session) {
output$plot <- renderImage({
x <- input$x
y <- input$y
v <- input$v
p <- ggplot(dfr, aes(x = !!sym(x), y = !!sym(y), col = !!sym(v))) +
geom_point() +
theme_bw() +
theme(legend.position = "top")
file <- htmltools::capturePlot(
print(p),
tempfile(fileext = ".svg"),
grDevices::svg,
width = 4,
height = 4
)
list(src = file)
}, deleteFile = TRUE)
}
shinyApp(ui = ui, server = server)
```
Create this dockerfile:
FROM ghcr.io/rocker-org/geospatial:4.4
RUN Rscript --verbose -e 'remotes::install_github("posit-dev/r-shinylive", upgrade = "never", verbose = TRUE)'
ENV XDG_CACHE_HOME=/tmp/quarto_cache_home
ENV XDG_DATA_HOME=/tmp/quarto_data_home
WORKDIR /home/rstudio/work
Then build image, add shinylive extension and render:
docker build --platform=linux/amd64 -t shinylivetest .
docker run --platform=linux/amd64 --rm -u 1000:1000 -v "${PWD}":/home/rstudio/work shinylivetest quarto add quarto-ext/shinylive --no-prompt
docker run --platform=linux/amd64 --rm -u 1000:1000 -v "${PWD}":/home/rstudio/work shinylivetest quarto render index.qmd
Versions
Click here
$ docker run --platform=linux/amd64 --rm -u 1000:1000 -v ${PWD}:/home/rstudio/work shinylivetest quarto check
Quarto 1.5.57
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.2.0: OK
Dart Sass version 1.70.0: OK
Deno version 1.41.0: OK
Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.5.57
Path: /usr/lib/rstudio-server/bin/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: Installation From Path
Path: /usr/local/texlive/bin/linux
Version: 2025
[✓] Checking basic markdown render....OK
[✓] Checking Python 3 installation....OK
Version: 3.12.3
Path: /usr/bin/python3
Jupyter: (None)
Jupyter is not available in this Python installation.
Install with python3 -m pip install jupyter
[✓] Checking R installation...........OK
Version: 4.4.3
Path: /usr/local/lib/R
LibPaths:
- /usr/local/lib/R/site-library
- /usr/local/lib/R/library
knitr: 1.50
rmarkdown: 2.29
[✓] Checking Knitr engine render......OK
$ docker run --platform=linux/amd64 --rm -u 1000:1000 -v ${PWD}:/home/rstudio/work shinylivetest Rscript -e "packageVersion('shinylive')"
[1] ‘0.3.0.9000’
$ docker --version
Docker version 28.1.1, build 4eba377
$ lsb_release -a
No LSB modules are available.
Distributor ID: Zorin
Description: Zorin OS 16.3
Release: 16
Codename: focal
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
