ThinkR-open / golem

A Framework for Building Robust Shiny Apps
https://thinkr-open.github.io/golem/
Other
904 stars 132 forks source link

Warning in `devtools::check()` after using `golem::use_utils_server()` #678

Closed JMPivette closed 3 years ago

JMPivette commented 3 years ago

After using golem::use_utils_server() I get a warning when running devtools::check():

> checking dependencies in R code ... WARNING
  '::' or ':::' import not declared from: 'rlang'

It looks like devtools::check() doesn't like this line: https://github.com/ThinkR-open/golem/blob/6d9e4517de9a247fd823fcd606370935ece8bce0/inst/utils/golem_utils_server.R#L62

If I change this line with rv <- function(...) shiny::reactiveValues(...) then the warning disappears.

I don't really understand why this warning appears in the first place. I am using R v4.0.2, golem v0.3.1 and devtools v2.4.1

ColinFay commented 3 years ago

Hey,

Thanks for reporting that.

Is this something you see systematically in your apps (i.e. every time you create a golem ?) or is it only this time?

JMPivette commented 3 years ago

Hey It's systematic. I noticed it on my last 2 projects using golem.

Then to find the cause of the warning, I created a blank golem project and ran devtools::check() after each command line in 01_start.R

The problem is reproducible (well at least on my computer..):

ColinFay commented 3 years ago

Reprex :

colin:tmp colin$ cd /tmp

colin:tmp colin$ Rscript -e "golem::create_golem('plop')"
[...] # Removed output

colin:tmp colin$ cd plop/

colin:plop colin$ Rscript -e "devtools::check()"
[...] # Removed output
── R CMD check results ──────────────────────────────────── plop 0.0.0.9000 ────
Duration: 1m 59.4s

❯ checking DESCRIPTION meta-information ... WARNING
  Spécification de licence non standard :
    What license is it under?
  Standardizable: FALSE

0 errors ✔ | 1 warning ✖ | 0 notes ✔
Erreur : R CMD check found WARNINGs

colin:plop colin$ Rscript -e "golem::use_utils_server()"
[...] # Removed output
── R CMD check results ──────────────────────────────────── plop 0.0.0.9000 ────
Duration: 1m 11.7s

❯ checking DESCRIPTION meta-information ... WARNING
  Spécification de licence non standard :
    What license is it under?
  Standardizable: FALSE

❯ checking dependencies in R code ... WARNING
  '::' or ':::' import not declared from: ‘rlang’

0 errors ✔ | 2 warnings ✖ | 0 notes ✔
Erreur : R CMD check found WARNINGs

This happens only with utils_server, but this doesn't make sense as there is no rlang there 🤔

ColinFay commented 3 years ago

Ah, I think I get it.

> rv <- shiny::reactiveValues
> rv
function (...) 
{
    args <- list(...)
    if ((length(args) > 0) && (is.null(names(args)) || any(names(args) == 
        ""))) 
        rlang::abort("All arguments passed to reactiveValues() must be named.")
    values <- .createReactiveValues(ReactiveValues$new())
    .subset2(values, "impl")$mset(args)
    values
}
<bytecode: 0x7ff791ca7378>
<environment: namespace:shiny>

will take the body of the functions, so when the app compiles, it has rlang::.

ColinFay commented 3 years ago

Fixed via https://github.com/ThinkR-open/golem/pull/688/files

Thanks again for your feedback!