bslib icon indicating copy to clipboard operation
bslib copied to clipboard

Error in `compile_data()` when using `bs_theme()`

Open LewisAJones opened this issue 2 months ago • 6 comments

I confirm I have updated to the latest version of bslib via remotes::install_github("rstudio/bslib").

Describe the problem

I am hitting a persistent error with bs_theme() that I am struggling to resolve:

Error in `compile_data()`:
! Error: argument `$color` of `rgba($color, $alpha)` must be a color
        on line 100:20 of ../../../../../../Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/bslib/builtin/bs5/shiny/_variables.scss, in function `rgba`
        from line 100:20 of ../../../../../../Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/bslib/builtin/bs5/shiny/_variables.scss
        from line 218:9 of stdin
>> $table-striped-bg: rgba($primary, 0.06) !default;

Reproducible example (note, I hit this issue locally, but not on posit Cloud so it may be OS-related?):

# Load library
library(bslib)
#> 
#> Attaching package: 'bslib'
#> The following object is masked from 'package:utils':
#> 
#>     page
# Update theme (from example in help notes)
theme <- bs_theme(
  # Controls the default grayscale palette
  bg = "#202123", fg = "#B8BCC2",
  # Controls the accent (e.g., hyperlink, button, etc) colors
  primary = "#EA80FC", secondary = "#48DAC6",
  base_font = c("Grandstander", "sans-serif"),
  code_font = c("Courier", "monospace"),
  heading_font = "'Helvetica Neue', Helvetica, sans-serif",
  # Can also add lower-level customization
  "input-border-color" = "#EA80FC"
)

Created on 2025-10-15 with reprex v2.1.1

Session Info


> devtools::session_info()
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.1 (2025-06-13)
 os       macOS Sequoia 15.6.1
 system   aarch64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/London
 date     2025-10-15
 rstudio  2025.09.1+401 Cucumberleaf Sunflower (desktop)
 pandoc   3.6.3 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
 quarto   1.6.40 @ /usr/local/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────── package * version date (UTC) lib source bslib * 0.9.0.9000 2025-10-15 [1] Github (rstudio/bslib@ba1be9a) cachem 1.1.0 2024-05-16 [1] CRAN (R 4.5.0) callr 3.7.6 2024-03-25 [1] CRAN (R 4.5.0) cli 3.6.5 2025-04-23 [1] CRAN (R 4.5.0) clipr 0.8.0 2022-02-22 [1] CRAN (R 4.5.0) devtools 2.4.6 2025-10-03 [1] CRAN (R 4.5.0) digest 0.6.37 2024-08-19 [1] CRAN (R 4.5.0) ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.5.0) evaluate 1.0.5 2025-08-27 [1] CRAN (R 4.5.0) fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.5.0) fs 1.6.6 2025-04-12 [1] CRAN (R 4.5.0) glue 1.8.0 2024-09-30 [1] CRAN (R 4.5.0) htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.5.0) jquerylib 0.1.4 2021-04-26 [1] CRAN (R 4.5.0) jsonlite 2.0.0 2025-03-27 [1] CRAN (R 4.5.0) knitr 1.50 2025-03-16 [1] CRAN (R 4.5.0) lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.5.0) magrittr 2.0.4 2025-09-12 [1] CRAN (R 4.5.0) memoise 2.0.1 2021-11-26 [1] CRAN (R 4.5.0) pillar 1.11.1 2025-09-17 [1] CRAN (R 4.5.0) pkgbuild 1.4.8 2025-05-26 [1] CRAN (R 4.5.0) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.5.0) pkgload 1.4.1 2025-09-23 [1] CRAN (R 4.5.0) processx 3.8.6 2025-02-21 [1] CRAN (R 4.5.0) ps 1.9.1 2025-04-12 [1] CRAN (R 4.5.0) purrr 1.1.0 2025-07-10 [1] CRAN (R 4.5.0) R6 2.6.1 2025-02-15 [1] CRAN (R 4.5.0) remotes 2.5.0 2024-03-17 [1] CRAN (R 4.5.0) reprex * 2.1.1 2024-07-06 [1] CRAN (R 4.5.0) rlang 1.1.6 2025-04-11 [1] CRAN (R 4.5.0) rmarkdown 2.30 2025-09-28 [1] CRAN (R 4.5.0) rstudioapi 0.17.1 2024-10-22 [1] CRAN (R 4.5.0) sass 0.4.10 2025-04-11 [1] CRAN (R 4.5.0) sessioninfo 1.2.3 2025-02-05 [1] CRAN (R 4.5.0) tibble 3.3.0 2025-06-08 [1] CRAN (R 4.5.0) usethis 3.2.1 2025-09-06 [1] CRAN (R 4.5.0) vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.5.0) withr 3.0.2 2024-10-28 [1] CRAN (R 4.5.0) xfun 0.53 2025-08-19 [1] CRAN (R 4.5.0) yaml 2.3.10 2024-07-26 [1] CRAN (R 4.5.0)

[1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library

  • ── Packages attached to the search path.

LewisAJones avatar Oct 15 '25 09:10 LewisAJones

Hi @LewisAJones, I'm not able to reproduce the error from the code you've provided. Seems there is some additional code/context that is missing given that the error derives from Shiny's Sass code.

Would you mind trying to include a minimal Shiny app to reproduce the error? This runs OK for me:

library(shiny)

theme <- bs_theme(
  bg = "#202123", fg = "#B8BCC2",
  primary = "#EA80FC", secondary = "#48DAC6",
  base_font = c("Grandstander", "sans-serif"),
  code_font = c("Courier", "monospace"),
  heading_font = "'Helvetica Neue', Helvetica, sans-serif",
  "input-border-color" = "#EA80FC"
)
ui <- fluidPage(
  theme = theme,
  "Reprex"
)

shinyApp(ui, function(input, output) {})

cpsievert avatar Oct 15 '25 14:10 cpsievert

Hi @cpsievert, thanks for taking a look! As I noted above, this seems to be potentially OS-related. I am not getting an error on Posit Cloud, but on my local machine for the same code and setup.

The code you've provided results in the same error as above for me:

> library(shiny)
+ 
+ theme <- bs_theme(
+   bg = "#202123", fg = "#B8BCC2",
+   primary = "#EA80FC", secondary = "#48DAC6",
+   base_font = c("Grandstander", "sans-serif"),
+   code_font = c("Courier", "monospace"),
+   heading_font = "'Helvetica Neue', Helvetica, sans-serif",
+   "input-border-color" = "#EA80FC"
+ )
+ ui <- fluidPage(
+   theme = theme,
+   "Reprex"
+ )
+ 
+ shinyApp(ui, function(input, output) {})
Error in `compile_data()`:
! Error: argument `$color` of `rgba($color, $alpha)` must be a color
        on line 100:20 of ../../../../../../Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/bslib/builtin/bs5/shiny/_variables.scss, in function `rgba`
        from line 100:20 of ../../../../../../Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library/bslib/builtin/bs5/shiny/_variables.scss
        from line 218:9 of stdin
>> $table-striped-bg: rgba($primary, 0.06) !default;

LewisAJones avatar Oct 15 '25 15:10 LewisAJones

Mind sharing your sessionInfo()?

cpsievert avatar Oct 15 '25 15:10 cpsievert

Of course, thanks!

> sessionInfo()
R version 4.5.1 (2025-06-13)
Platform: aarch64-apple-darwin20
Running under: macOS Sequoia 15.6.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] bslib_0.9.0  shiny_1.11.1

loaded via a namespace (and not attached):
 [1] digest_0.6.37     later_1.4.4       R6_2.6.1          httpuv_1.6.16     fastmap_1.2.0     magrittr_2.0.4    cachem_1.1.0      htmltools_0.5.8.1
 [9] lifecycle_1.0.4   promises_1.3.3    cli_3.6.5         sessioninfo_1.2.3 xtable_1.8-4      sass_0.4.10       jquerylib_0.1.4   compiler_4.5.1   
[17] tools_4.5.1       mime_0.13         yaml_2.3.10       Rcpp_1.1.0        jsonlite_2.0.0    rlang_1.1.6  

LewisAJones avatar Oct 15 '25 15:10 LewisAJones

Huh, strange. Just to make sure, if you run that code snippet from a new/clean R session, does it still error?

cpsievert avatar Oct 15 '25 15:10 cpsievert

Yes, I've tried new/clean R sessions, updating R, reinstalling shiny/bslib :')

I'm completely bewildered by it!

LewisAJones avatar Oct 15 '25 15:10 LewisAJones