rrstudiobookdownrsconnect

Turn off the update prompt when republishing a book


When using bookdown::publish_book() to republish a book I get a prompt in the console:

Update application currently deployed at https://bookdown.org/..../..../? [Y/n]

How can I turn that prompt off?

I need to turn it off since the book should be republished on a regular basis from a script run automatically on an R server. In one of the underlying functions rsconnect::deployApp() I found the option "getOption("rsconnect.force.update.apps", TRUE)" but I can't/don't know how to access that from the publish_book() function.

Thanks!


Solution

  • The rsconnect::deployApp function has argument

    forceUpdate = getOption("rsconnect.force.update.apps", FALSE)
    

    If you set that argument to TRUE, it should force the update without prompting. But since you aren't calling deployApp directly, you need to set the default value of that argument to be TRUE, which you can do by

    options(rsconnect.force.update.apps = TRUE)
    

    You might not want to do this always (sometimes you want the question). If you want it set only for the duration of your bookdown::publish_book() call, do it like this:

    withr::with_options(c(rsconnect.force.update.apps = TRUE),
                        bookdown::publish_book())