rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
977 stars 152 forks source link

Having some issues when using rsconnect and renv - parseRenvDependencies() #1923

Open ntyndall opened 2 weeks ago

ntyndall commented 2 weeks ago

Hi,

I think this is partly my misunderstanding of how to deploy to shinyapps using rsconnect and renv.

I have a script called DEPLOY.R which is essentially just

setwd() # sets to root folder location 
renv::load()
rsconnect::setAccountInfo()
rsconnect::deployApp()

I literally just open up Rstudio and call source('DEPLOY.R'), but I'm getting the following error with backtrace, am I missing setting some env variables or doing things in the wrong order?

i Capturing R dependencies from renv.lock
Error in `parseRenvDependencies()` at rsconnect/R/bundlePackage.R:59:4:
! Library and lockfile are out of sync
i Use renv::restore() or renv::snapshot() to synchronise
i Or ignore the lockfile by adding to your .rscignore
Backtrace:
    x
1. \-rsconnect::deployApp(appDir = DEST)
2.   \-rsconnect:::bundleApp(...) at rsconnect/R/deployApp.R:419:4
3.     \-rsconnect:::createAppManifest(...) at rsconnect/R/deployApp.R:611:2
4.       \-rsconnect:::bundlePackages(...) at rsconnect/R/bundle.R:118:4
5.         \-rsconnect:::computePackageDependencies(...) at rsconnect/R/bundlePackage.R:7:2
6.           \-rsconnect:::parseRenvDependencies(bundleDir) at rsconnect/R/bundlePackage.R:59:4
7.             \-cli::cli_abort(...) at rsconnect/R/bundlePackageRenv.R:43:6
8.               \-rlang::abort(...)

I have tried running things like restore or snapshot in the script, but it just says lockfile is up to date or library is synchronized (as it should be). Note that if I open up the .Rproj file in Rstudio and run through the same code in DEPLOY.R then this works as expected and deploys successfully! OR if I open Rstudio and open the actual project and use source() then it also works. I suppose long story short I would want to be able to do something like "Rscript.exe" -e "source('DEPLOY.R')" from the command line..

SessionInfo

R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2012 R2 x64 (build 9600)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=C                              

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] magrittr_2.0.1

loaded via a namespace (and not attached):
[1] digest_0.6.27   bit_4.0.4       odbc_1.3.2      blob_1.2.2      pkgconfig_2.0.3 bit64_4.0.5     lifecycle_1.0.0 cli_3.6.2      
 [9] askpass_1.1     openssl_2.1.0   vctrs_0.3.8     DBI_1.1.1       renv_1.0.3      rsconnect_1.0.2 compiler_4.3.2  purrr_0.3.4    
[17] rstudioapi_0.13 tools_4.3.2     curl_4.3.2      hms_1.1.0       ellipsis_0.3.2  Rcpp_1.0.7      jsonlite_1.7.2  rlang_1.1.1

Thank you!

shotgun1 commented 2 weeks ago

Have you tried populating missing packages in your DESCRIPTION file...

ntyndall commented 2 weeks ago

Have you tried populating missing packages in your DESCRIPTION file...

Thanks for the reply! So maybe I'm picking you up wrong - but I don't actually have any missing packages. I have them installed in my cache and sitting in ~/project/renv/library. Without going totally off piste here, I have a combination of R 3.6.3 and RENV 0.13.2 installed and I can source a file to deploy using rsconnect.. it only seems to be after bumping versions that I am running into this issue!

shotgun1 commented 2 weeks ago

Try setting your code up in a package format using renv, then simply run rsconnect deployApp directly in console. That should work.

On 17 Jun 2024, at 16:43, Niall Tyndall @.***> wrote:



Have you tried populating missing packages in your DESCRIPTION file...

Thanks for the reply! So maybe I'm picking you up wrong - but I don't actually have any missing packages. I have them installed in my cache and sitting in ~/project/renv/library. Without going totally off piste here, I have a combination of R 3.6.3 and RENV 0.13.2 installed and I can source a file to deploy using rsconnect.. it only seems to be after bumping versions that I am running into this issue!

— Reply to this email directly, view it on GitHubhttps://github.com/rstudio/renv/issues/1923#issuecomment-2173747747, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC32CP4M7BX2XROCXGP53EDZH37YDAVCNFSM6AAAAABJH4KTHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZTG42DONZUG4. You are receiving this because you commented.Message ID: @.***>

kevinushey commented 2 weeks ago

I suspect you'll have better luck filing this at https://github.com/rstudio/rsconnect/issues, because (as far as I can see) this is more likely to be an issue with how rsconnect is using renv, rather than an issue in renv itself.

That said, the output of:

renv::load()
renv::status()

or even

renv::diagnostics()

may be useful.