rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
131 stars 80 forks source link

Unable to publish Shiny App to RStudio Connect #934

Closed DEQabrits closed 1 year ago

DEQabrits commented 1 year ago

I recently tried to update a shiny app I had published (last update was 3/7/2023) after updating to rsconnect version 1.0.1 and ran into the following error:

-- Preparing for deployment ---------------------------------------------------- v Re-deploying "shinynpdes_awqms2" to "server: rstudioconnect.deq.state.or.us / username: l_abritson" i Looking up application with id "47"... v Found application https://rstudioconnect.deq.state.or.us/content/09545f4b-3d21-4ad2-aff7-600e956289e9/ i Bundling 10 files: 'AlBLM_Transform.R', 'app.R', 'CalcHardness_Function.R', 'Continuous_Summary_Function.R', 'MonteCarlo.R', 'NameandFraction.R', 'NPDES_AWQMSQuery.R', 'query_cache.RData', 'query_cache_allchar.RData', and 'README.md' i Capturing R dependencies with renv 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

I tried running options(rsconnect.packrat = TRUE) as was recommended in the package description, but it did not seem to work. Please let me know if there is more information you need, this is my first time posting an issue.

aronatkins commented 1 year ago

Could you try installing the development version of renv and report back if that changes the behavior?

remotes::install_github("rstudio/renv")

Could you also try deploying from the R console to see if that provides any additional feedback?

# Unset the option so we use renv.
options(rsconnect.packrat = NULL)
rsconnect::deployApp()

You should be able to bypass the use of renv when deploying from the R console:

options(rsconnect.packrat = TRUE)
rsconnect::deployApp()

Unfortunately, that option does not appear to alert the R session that is used by the Deploy pane for push-button deployment. I have filed https://github.com/rstudio/rsconnect/issues/935 to track the fact that the rsconnect.packrat option is not effective when using push-button deploys.

If you are still having trouble with the latest version of renv, you will need to install the previous rsconnect release until we can solve your problem.

remotes::install_version("rsconnect", "0.8.29")

Reverting rsconnect should let you use the deployment button again.

DEQabrits commented 1 year ago

Thank you for your prompt response! I tried installing the development version of renv and it did not change the behavior. Deploying from the R console also unfortunately did not provide any additional feedback; just the same error message I received earlier (but in multiple colors). Thankfully bypassing the use of renv using the code you supplied worked and I was able to publish my updates.

I appreciate your help!

aronatkins commented 1 year ago

@kevinushey & @hadley - Do you have any advice to have renv emit additional information about the preflight issue?

@DEQabrits Is there any chance that you could narrow your application into something you would be willing to share with us?

kevinushey commented 1 year ago

You'll need to ensure renv.verbose = TRUE is set. It looks like that's being explicitly set to FALSE here:

https://github.com/rstudio/rsconnect/blob/a5db8323584ecc682332d8b59d172827a253a06e/R/bundlePackageRenv.R#L6-L10

DEQabrits commented 1 year ago

@kevinushey & @hadley - Do you have any advice to have renv emit additional information about the preflight issue?

@DEQabrits Is there any chance that you could narrow your application into something you would be willing to share with us?

That application would be difficult. But I did get the same issue with another one of my applications that I can share more easily: https://github.com/OR-Dept-Environmental-Quality/FlowDataPull.

aronatkins commented 1 year ago

Thanks for that project, @DEQabrits. In experimenting with it, I did uncover one type of (related) error that is not revealing much feedback. I've filed that as https://github.com/rstudio/renv/issues/1607.

Could you run these commands from the R console within your original project and tell us if any details are provided?

options(renv.consent = TRUE)
deps <- renv::dependencies(getwd())
renv::snapshot(getwd(), packages = deps$Package, prompt = FALSE)

If these steps happen to create an renv.lock file, you should remove it since your project is not an renv project.

unlink("renv.lock")
aronatkins commented 1 year ago

@DEQabrits - I think I figured out the problem. You have the dflowR package installed from source rather than from CRAN or GitHub. renv is not reporting this problem, but it should.

Could you try the following before deploying again?

devtools::install_github("OR-Dept-Environmental-Quality/dflowR")

Installing like this will record information about where the package came from, which renv then uses when creating its snapshot. I've filed https://github.com/rstudio/renv/issues/1608 to track this problem.

DEQabrits commented 1 year ago

@aronatkins - I ran the commands in the R console and I got a lot more details that what was originally provided. I've copied it below.

options(renv.consent = TRUE)

deps <- renv::dependencies(getwd()) Finding R package dependencies ... [10/10] Done! renv::snapshot(getwd(), packages = deps$Package, prompt = FALSE) The following required packages are not installed: - downlit [required by pkgdown] - httr2 [required by gh]
Consider reinstalling these packages before snapshotting the lockfile.

The following package(s) have unsatisfied dependencies:

aronatkins commented 1 year ago

@DEQabrits - Thanks so much for your continued involvement. It sounds like each of those problems are indeed issues that should have blocked deployment, but neither rsconnect nor renv were reporting them correctly. Would you agree with that assessment?

After installing the suggested packages and package updates, are you able to deploy?

hadley commented 1 year ago

@DEQabrits you should be able to eliminate many of those problems by either commenting out or replacing devtools with remotes on this line: https://github.com/OR-Dept-Environmental-Quality/FlowDataPull/blob/main/USGSdatapull.R#L72-L74 (and this will generally make a bundle that's much smaller to deploy)

DEQabrits commented 1 year ago

@aronatkins - Yes, I agree with that assessment. After installing the packages/updates I was able to deploy.

@hadley Thank you for the suggestion! I plan on doing so.

aronatkins commented 1 year ago

The renv-1.0.1 release contains the https://github.com/rstudio/renv/issues/1608 fix; closing this issue as resolved.

Please open a new issue if you encounter other problems.