I was ready to deploy a shiny app to posit-connect. It is hosted in the same instance with posit workbench where the app was developed. Renv was initiated and snapshot and renv.lock was created. There was one package ("sage") installed using local tar.gz instead of any external repository. Inside renv.lock, that package was locked like below, RENV_PATHS_CELLAR="/staging/home/csu03/shinyapps/sage_shiny/renv/cellar/" was added to project .Renviron, and package tarball was copied to RENV_PATHS_CELLAR path.
After restart R session (and renv loaded), deployment looks capturing R dependencies from renv.lock. However, the deployment failed at packrat::restore() step. The installation of sage package still look for the repository.
Installing sage (1.3.2) ...
curl: HTTP 404 https://cran.rstudio.com/src/contrib/Archive/sage/sage_1.3.2.tar.gz
curl: (22) The requested URL returned error: 404
curl: HTTP 404 https://cran.rstudio.com/src/contrib/Archive/sage/sage_1.3.2.tar.gz
curl: (22) The requested URL returned error: 404
curl: HTTP 404 https://cran.rstudio.com/src/contrib/Archive/sage/sage_1.3.2.tar.gz
curl: (22) The requested URL returned error: 404
curl: HTTP 404 https://cran.rstudio.com/src/contrib/Archive/sage/sage_1.3.2.tar.gz
curl: (22) The requested URL returned error: 404
curl: HTTP 404 https://cran.rstudio.com/src/contrib/Archive/sage/sage_1.3.2.tar.gz
curl: (22) The requested URL returned error: 404
FAILED
Error in getSourceForPkgRecord(pkgRecord, srcDir(project), availablePackagesSource(repos = repos), : Failed to retrieve package sources for sage 1.3.2 from CRAN (internet connectivity issue?)
Unable to fully restore the R packages associated with this deployment.
Please review the preceding messages to determine which package
encountered installation difficulty and the cause of the failure.
An error occurred while building your content.
Any additional steps need to be done to allow deployment find local tarball file for installation of package?
Is the package available from some internal repository / code host? Even if Connect and Workbench are installed on the same system (which we do not recommend), Connect's default behavior is to attempt to recreate the package environment using the repositories it has access to.
Setting a GitCredential for your code host would be one way to get Connect to access the package remotely. You would also want to install the package in your local environment from the code host so that its location is recorded appropriately before deployment.
Another option is to deploy install the packages needed for your application, including sage, in the system library and then disable environment management for this deployment, as described here. You can also see the docs for rsconnect::deployApp(envManagementR=FALSE)
Finally, you can mark sage as an external package, as described here.
The package was internally hosted on gitlab. However, due to the huge size of the package (~3GB), using devtools::install_gitlab failed to download the source due to its size, which led met to download tarball to local and installed it from source in the system. Thus option 1 does not work (unless you can provide alternatives).
For the second option, i tested ignore renv.lock by adding renv.lock to .rscignore file. The deployment was complete. However, the app show errors. I checked the log which led to the wrong R_LIBS location (/opt/R/4.2.1/lib/R/library). i added enVars options in the deployApp rsconnect::deployApp(envManagementR=FALSE, envVars=c("R_LIBS"="/staging/home/csu03/shinyapps/sage_shiny/renv/library/R-4.2/x86_64-pc-linux-gnu/")), however, the deployed app still cannot find the right LIBS path. Any suggestion on this?
For the external package options, I run packrat::set_opts("external.packages"=c("sage")) before deployment, the error was like before ("still look for installation of sage from CRAN repo").
Option 1: I think it depends a bit on what caused the download to fail. For example if some internal proxy restricts the size of files you can download, you might consider bringing that to the attention of the relevant administrators. The package is cached on Connect once downloaded, so you could only need to install it once per package version X R version.
Options 2 and 3 require you to modify the system R package library. Option 3 would require you to modify Connect's configuration as well.
A little update on the option 1. I finally was able to install sage from internal gitlab in the system after increasing the timeout options. However, the deployment still fails.
Error in downloadWithRetries(url, destfile = destfile): Failed to download package from GitLab URL: 'https://gitlab.nimbus.amgen.com/api/v4/projects/tnguye07%2Fsage/repository/archive?sha=1fc023b7a608e3033740fc735aee6f1757a5fcdc'
Download failed.
If you are trying to restore a package from a private Git repo, you must have credentials available in your environment, and Packrat must be configured to use an auth-capable download method. GITLAB_PAT environment variable not found. Packrat is not configured to use an auth-capable download method. Try setting the option packrat.authenticated.downloads.use.renv to TRUE, or installing the httr package.
The error is not correct given I already provided GITLAB_PAT, GITLAB_URL in project .Renviron, set options packrat.authenticated.downloads.use.renv to TRUE, timeout to 400000, and installed the httr package in project. I think the problem still lies on the package size is too big to be downloaded.
May I ask how to limit this configuration to the project/user scope instead of global platform? Based on the link you provided, it required admin to prepare global configuration at /etc/rstudio-connect/rstudio-connect.gcfg.
I deployed an app a while back to the same connect host using rsconnect_1.1.1 (the current app rsconnect_1.3.4). The project .Renviron were enough for deployment. Not sure whether there is any change between versions to request this additional configuration.