rstudio / rsconnect

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

prefer RSCONNECT_PACKRAT over rsconnect.packrat #937

Closed aronatkins closed 1 year ago

aronatkins commented 1 year ago

Environment variables are visible in the RStudio IDE R session used for push-button deployment. Not all R options are mirrored into that session.

These settings indicate that packrat should be used, even in the presence of an renv.lock. When using packrat, the renv directory and renv.lock file are removed from the bundle directory, as would happen prior to rsconnect 1.0.0.

Fixes #935 Fixes #936

# Unset any existing options before testing.
Sys.unset("RSCONNECT_PACKRAT")
options(reconnect.packrat = NULL)

# Use packrat; applies to push-button and console deploys.
# Ignores renv.lock if it exists.
Sys.setenv(RSCONNECT_PACKRAT = "TRUE")

# Use packrat; applies to console deploys only. Discouraged.
# Ignores renv.lock if it exists.
options(rsconnect.packrat = TRUE)

# If both are set, the environment variable setting wins.
# This example will use renv because RSCONNECT_PACKRAT is set.
Sys.setenv(RSCONNECT_PACKRAT = "FALSE")
options(rsconnect.packrat = TRUE)