-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid R package warning in loadSupport()
if autoload is disabled
#3513
Conversation
@krlmlr Can you provide instructions on how to reproduce the issue? |
Create a Shiny app with a package structure (with Do we need a test here? |
3331b00
to
2c9ceee
Compare
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
}) |
2c9ceee
to
3cea593
Compare
R/shinyapp.R
Outdated
if (length(disabled) > 0){ | ||
return(invisible(renv)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krlmlr maybe simpler to move this early exit on disabled to L356 instead of extending the if clause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on a change like that... will push back to this PR in a minute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the end, I think the warning was happening too early. By moving it down we can instead warn just before evaluating the code in the R/
support directory.
loadSupport()
if autoload is disabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for picking this up!
Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
in
loadSupport()
, if_disable_autoload.R
exists.