Consider moving yaml package from Suggests to Imports to avoid issues trying to use _brand.yml in non-interactive R sessions
Nobody has claimed this yet.
- Dominant language
- SCSS
- Stars
- 569
- Forks
- 72
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 5
Description
Describe the problem
_brand.yml not being read if the yaml package is not installed .
The developer gets no notification why it is not being read if:
- they are using the default arguments for bs_theme() AND
- R is being run in a non-interactive session such as a docker container with a CMD instruction such as:
CMD ["R", "-e", "options(shiny.autoload.r = TRUE)" ,"-e", "shiny::runApp( port = 3838, host = '0.0.0.0')"]
The cause is not easily identifiable if the shiny app is being run from an R session where interactive() is FALSE such as a docker container.
In interactive sessions when read_brand_yaml() is eventually called from the exported function bs_theme , the call to rlang::check_installed("yaml") prompts the user to install the missing package.
In non-interactive sessions the call to rlang::check_installed("yaml") returns an error.
This error gets caught by a trycatch in brand_resolve.NULL and the calling bs_theme() function replaces the null brand with bootstrap defaults.
it was really difficult to figure out why my brand settings weren't appearing in the container version of the app compared to local development until i realised that the container version only had shiny, bslib and the packages listed in their Imports installed.
Is it possible:
- to add the yaml package to bslib's Imports instead of Suggests and not rely on
rlang::check_installed()? OR - add some documentation for developers to recommend they install yaml when they want to use _brand.yml and their app or dashboard is not going to be run in interactive sessions?
Thanks for reading, I hope I have been able to describe with enough clarity.
reprex1 -
calling bs_theme(brand = NULL) from a non-interactive session returns default bundle etc but not the settings in _brand.yml supplied by the developer
root@4cfca3da1d1a:/app# R -e "rlang::is_installed('yaml')" -e "bslib::bs_theme(brand = NULL)" -e "bslib::bs_theme(brand = NULL) |> attr('brand') |> getElement('path')"
R version 4.5.0 (2025-04-11) -- "How About a Twenty-Six"
...
> rlang::is_installed('yaml')
[1] FALSE
> bslib::bs_theme(brand = NULL)
/* Sass Bundle: _utilities, _root, _reboot, _type, _images, _containers, _grid, _tables, _forms, _buttons, _transitions, _dropdown, _button-group, _nav, _navbar, _card, _accordion, _breadcrumb, _pagination, _badge, _alert, _progress, _list-group, _close, _toasts, _modal, _tooltip, _popover, _carousel, _spinners, _offcanvas, _placeholders, _helpers, _api, bs3compat, builtin */
@import "/usr/local/lib/R/site-library/bslib/lib/bs5/scss/_functions.scss";
@import "/usr/local/lib/R/site-library/bslib/bslib-scss/functions.scss";
...
$bslib-preset-type: builtin;
$bslib-preset-name: shiny;
$web-font-path: "font.css" !default;
...
> bslib::bs_theme(brand = NULL) |> attr('brand') |> getElement('path')
NULL
reprex 2 calling bs_theme(brand = TRUE) from a non-interactive session returns an error
root@4cfca3da1d1a:/app# R -e "rlang::is_installed('yaml')" -e "bslib::bs_theme(brand = TRUE)"
R version 4.5.0 (2025-04-11) -- "How About a Twenty-Six"
...
> rlang::is_installed('yaml')
[1] FALSE
> bslib::bs_theme(brand = TRUE)
Error in read_brand_yml(NULL) : The package "yaml" is required.
Calls: <Anonymous> ... brand_resolve.logical -> read_brand_yml -> <Anonymous>
Execution halted
reprex 3 calling calling bs_theme(brand = NULL) from a non-interactive session when the yaml package IS installed
root@4cfca3da1d1a:/app# R -e "rlang::is_installed('yaml')" -e "bslib::bs_theme(brand = NULL) |> attr('brand') |> getElement('path')"
R version 4.5.0 (2025-04-11) -- "How About a Twenty-Six"
...
> rlang::is_installed('yaml')
[1] TRUE
> bslib::bs_theme(brand = NULL) |> attr('brand') |> getElement('path')
[1] "/app/_brand.yml"
Session Info
─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── setting value version R version 4.5.0 (2025-04-11) os Ubuntu 22.04.1 LTS system x86_64, linux-gnu ui X11 language (EN) collate en_US.UTF-8 ctype en_US.UTF-8 tz UTC date 2025-04-22 pandoc NA quarto NA─ Packages ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date (UTC) lib source
bspm 0.5.7 [2] local
cachem 1.1.0 2024-05-16 [2] RSPM (R 4.4.0)
cli 3.6.4 2025-02-13 [2] RSPM (R 4.4.0)
devtools 2.4.5 2022-10-11 [2] RSPM (R 4.2.0)
digest 0.6.37 2024-08-19 [2] RSPM (R 4.4.0)
ellipsis 0.3.2 2021-04-29 [2] RSPM (R 4.2.0)
fastmap 1.2.0 2024-05-15 [2] RSPM (R 4.4.0)
fs 1.6.6 2025-04-12 [2] RSPM (R 4.4.0)
glue 1.8.0 2024-09-30 [2] RSPM (R 4.4.0)
htmltools 0.5.8.1 2024-04-04 [2] RSPM (R 4.3.0)
htmlwidgets 1.6.4 2023-12-06 [2] RSPM (R 4.3.0)
httpuv 1.6.16 2025-04-16 [2] RSPM (R 4.4.0)
later 1.4.2 2025-04-08 [2] RSPM (R 4.4.0)
lifecycle 1.0.4 2023-11-07 [2] RSPM (R 4.3.0)
magrittr 2.0.3 2022-03-30 [2] RSPM (R 4.2.0)
memoise 2.0.1 2021-11-26 [2] RSPM (R 4.2.0)
mime 0.13 2025-03-17 [2] RSPM (R 4.4.0)
miniUI 0.1.2 2025-04-17 [2] RSPM (R 4.4.0)
pkgbuild 1.4.7 2025-03-24 [2] RSPM (R 4.4.0)
pkgload 1.4.0 2024-06-28 [2] RSPM (R 4.4.0)
profvis 0.4.0 2024-09-20 [2] RSPM (R 4.4.0)
promises 1.3.2 2024-11-28 [2] RSPM (R 4.4.0)
purrr 1.0.4 2025-02-05 [2] RSPM (R 4.4.0)
R6 2.6.1 2025-02-15 [2] RSPM (R 4.4.0)
Rcpp 1.0.14 2025-01-12 [2] RSPM (R 4.4.0)
remotes 2.5.0 2024-03-17 [2] RSPM (R 4.3.0)
rlang 1.1.6 2025-04-11 [2] RSPM (R 4.4.0)
sessioninfo 1.2.3 2025-02-05 [2] RSPM (R 4.4.0)
shiny 1.10.0 2024-12-14 [2] RSPM (R 4.4.0)
urlchecker 1.0.1 2021-11-30 [2] RSPM (R 4.2.0)
usethis 3.1.0 2024-11-26 [2] RSPM (R 4.4.0)
vctrs 0.6.5 2023-12-01 [2] RSPM (R 4.3.0)
xtable 1.8-4 2019-04-21 [2] RSPM (R 4.2.0)
[1] /usr/local/lib/R/site-library
[2] /usr/lib/R/site-library
[3] /usr/lib/R/library
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the three non-interactive bs_theme() cases described, with and without yaml installed. Read bs_theme(), read_brand_yml(), and brand_resolve.NULL to trace how the missing package error is handled. Done means the intended behavior for _brand.yml in non-interactive sessions is established and covered, including the dependency or documentation change selected by the maintainers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100