Skip to content
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

Suddenly unable to deploy shiny app due to renv error: aborting snapshot due to pre-flight validation failure #1903

Open
jzadra opened this issue May 15, 2024 · 4 comments

Comments

@jzadra
Copy link

jzadra commented May 15, 2024

Today I am suddenly unable to deploy my golem shiny app to shinyapps.io. I have made minor changes to the app but nothing I'm aware of that would affect the deployment, and the app works fine locally.

I did upgrade Rstudio to the most recent version this morning.

The error provides nothing to go on for troubleshooting as far as I can see.

I should also note that I don't use renv for this project, so I'm not sure why it's running.

── Preparing for deployment ────────────────────────────────────────────────────
✔ Re-deploying "xxx" using "server: shinyapps.io / username: xxx"
ℹ Looking up application with id "xxx"...
✔ Found application
ℹ Bundling 74 files: .here, .Rbuildignore, app.R, CODE_OF_CONDUCT.md, DESCRIPTION, dev/01_start.R, dev/02_dev.R, dev/03_deploy.R, dev/config_attachment.yaml, dev/run_dev.R, man/figures/README-pressure-1.png, man/mod_filter_ui.Rd, man/run_app.Rd, NAMESPACE, NEWS.md, README.md, README.Rmd, scratch/app structure reprex - cicerone.R, …, R/utils_cicerone.R, and R/utils_helpers.R
ℹ Capturing R dependencies with renv
The following package(s) were installed from an unknown source:

  • pfas.shiny.golem [0.0.0.9000]
    renv may be unable to restore these packages in the future.
    Consider reinstalling these packages from a known source (e.g. CRAN).

Traceback (most recent calls last):
9: rsconnect::deployApp(appDir = "~/Documents/R Projects/pfas.shiny.golem",
appFileManifest = "/var/folders/mp/w8f9_2c572dfzd9nf4363_lw0000gn/T/02ae-80b4-975c-c128",
account = "xxx", server = "shinyapps.io", appName = "xxx",
appTitle = "xxx", launch.browser = function(url) {
message("Deployment completed: ", url)
}, lint = FALSE, metadata = list(asMultiple = FALSE, asStatic = FALSE))
8: bundleApp(appName = deployment$name, appDir = appDir, appFiles = appFiles,
appMetadata = appMetadata, quiet = quiet, verbose = verbose,
pythonConfig = pythonConfig, image = image, envManagement = envManagement,
envManagementR = envManagementR, envManagementPy = envManagementPy)
7: createAppManifest(appDir = bundleDir, appMetadata = appMetadata,
users = users, pythonConfig = pythonConfig, retainPackratDirectory = TRUE,
image = image, envManagement = envManagement, envManagementR = envManagementR,
envManagementPy = envManagementPy, verbose = verbose, quiet = quiet)
6: bundlePackages(bundleDir = appDir, extraPackages = extraPackages,
verbose = verbose, quiet = quiet)
5: computePackageDependencies(bundleDir, extraPackages, quiet = quiet,
verbose = verbose)
4: snapshotRenvDependencies(bundleDir, extraPackages, verbose = verbose)
3: renv::snapshot(bundleDir, packages = deps$Package, prompt = FALSE)
2: renv_snapshot_validate_report(valid, prompt, force)
1: stop("aborting snapshot due to pre-flight validation failure")
Error in renv_snapshot_validate_report(valid, prompt, force) :
aborting snapshot due to pre-flight validation failure
Calls: ... snapshotRenvDependencies -> -> renv_snapshot_validate_report
Execution halted

Sysinfo:

MacOS 23.4.0
Rstudio: 2024.04.1+748
R: 4.3.0
Renv: 1.0.7
rsconnect: 1.2.2

@kevinushey
Copy link
Collaborator

kevinushey commented May 16, 2024

ℹ Capturing R dependencies with renv
The following package(s) were installed from an unknown source:

pfas.shiny.golem [0.0.0.9000]
renv may be unable to restore these packages in the future.
Consider reinstalling these packages from a known source (e.g. CRAN).

Are you using a package called pfas.shiny.golem? If so, how did you install it? Where does it live?

Newer versions of rsconnect use renv behind the scenes when collecting package dependencies, which is why you're probably seeing this.

@jzadra
Copy link
Author

jzadra commented May 16, 2024

pfas.shiny.golem is the name of the app that I am attempting to publish.

@kevinushey
Copy link
Collaborator

Most likely, renv is seeing something like library(pfas.shiny.golem) and is incorrectly inferring your project depends on that package (as though it were an external dependency). This is just speculation without a reproducible example, though.

You could try explicitly ignoring your package as a dependency, e.g.

renv::settings$ignored.packages("pfas.shiny.golem")

but you might have better luck filing this at https://github.com/rstudio/rsconnect/issues if this doesn't help.

@jzadra
Copy link
Author

jzadra commented May 23, 2024

Hi Kevin, just to followup:

  1. The only place I found a reference in code to the package was in the golem created file app.r which has:
# Launch the ShinyApp (Do not remove this comment)
# To deploy, run: rsconnect::deployApp()
# Or use the blue button on top of this file

pkgload::load_all(export_all = FALSE,helpers = FALSE,attach_testthat = FALSE)
options( "golem.app.prod" = TRUE)
pfas.shiny.golem::run_app() # add parameters here (if any)

There is also reference to it in testthat.R:

library(testthat)
library(pfas.shiny.golem)

test_check("pfas.shiny.golem")

Otherwise there are references in documentation, several that define the app name, and then two other golem specific files: inst/golem-config.yml and app_config.R:

#' Access files in the current app
#'
#' NOTE: If you manually change your package name in the DESCRIPTION,
#' don't forget to change it here too, and in the config file.
#' For a safer name change mechanism, use the `golem::set_golem_name()` function.
#'
#' @param ... character vectors, specifying subdirectory and file(s)
#' within your package. The default, none, returns the root of the app.
#'
#' @noRd
app_sys <- function(...) {
  system.file(..., package = "pfas.shiny.golem")
}


#' Read App Config
#'
#' @param value Value to retrieve from the config file.
#' @param config GOLEM_CONFIG_ACTIVE value. If unset, R_CONFIG_ACTIVE.
#' If unset, "default".
#' @param use_parent Logical, scan the parent directory for config file.
#' @param file Location of the config file
#'
#' @noRd
get_golem_config <- function(
  value,
  config = Sys.getenv(
    "GOLEM_CONFIG_ACTIVE",
    Sys.getenv(
      "R_CONFIG_ACTIVE",
      "default"
    )
  ),
  use_parent = TRUE,
  # Modify this if your config file is somewhere else
  file = app_sys("golem-config.yml")
) {
  config::get(
    value = value,
    config = config,
    file = file,
    use_parent = use_parent
  )
}

So I'm not sure whether any of those should be caught by renv and may be causing the problem, and I haven't tried removing them yet, because as much trouble as I have with renv, taking a snapshot before publishing works ok.

Also a note, renv::settings$ignored.packages("pfas.shiny.golem") does not affect the error (when not using renv::snapshot), so perhaps the way rsconnect is calling renv is ignoring that setting or not accessing it because it's deploying in a fresh environment?

I'll take this over to rsconnect issues though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants