shiny icon indicating copy to clipboard operation
shiny copied to clipboard

Avoid bogus warning

Open krlmlr opened this issue 4 years ago • 3 comments

in loadSupport(), if _disable_autoload.R exists.

krlmlr avatar Sep 29 '21 12:09 krlmlr

@krlmlr Can you provide instructions on how to reproduce the issue?

wch avatar Sep 29 '21 16:09 wch

Create a Shiny app with a package structure (with DESCRIPTION and NAMESPACE files) that contains a file R/_disable_autoload.R and uses e.g. pkgload::load_all() to load the files in R/ . The warning still occurs.

Do we need a test here?

krlmlr avatar Sep 30 '21 02:09 krlmlr

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 08 '23 16:11 CLAassistant

Minimal code for reproducing bogus warning here:

withr::with_dir(tempdir(check = TRUE),{
  dir.create("R", showWarnings = FALSE)
  # loadSupport documentation suggests adding a blank R/_disable_autoload.R file
  # will disable automatic loading of the R/ files
  file.create("R/_disable_autoload.R")
  # test that code was not loaded by adding a print statement
  writeLines(
    "print('R/ code was sourced')",
    "R/code.R"
  )
  # loadSupport checks for a NAMESPACE file and/or a DESCRIPTION file to determine
  # if the directory contains a package, add NAMESPACE to trigger the check
  file.create("NAMESPACE")
  # add minimal app.R code
  writeLines(
    text = "
    shiny::shinyApp(
      ui = shiny::fluidPage(), 
      server = function(input, output, session) {}
    )
    ", 
    con = "app.R"
  )
  shiny::runApp()
  # still triggers warning, despite not actually running the code in question
})

tanho63 avatar Mar 09 '24 21:03 tanho63