Debian Codegraph @

inst/doc/rsconnect.Rmd

raw
1 ---
2 title: "Using renv with Posit Connect"
3 output: rmarkdown::html_vignette
4 vignette: >
5 %\VignetteIndexEntry{Using renv with Posit Connect}
6 %\VignetteEncoding{UTF-8}
7 %\VignetteEngine{knitr::rmarkdown}
8 editor_options:
9 markdown:
10 wrap: 72
11 ---
12
13 ```{r, include=FALSE}
14 knitr::opts_chunk$set(
15 collapse = TRUE,
16 comment = "#>",
17 eval = FALSE
18 )
19 ```
20
21 [Posit Connect](https://posit.co/products/enterprise/connect) is a publication
22 platform for deploying content built in R and Python to share with a broad
23 audience. R users may want to develop content (like [Shiny
24 applications](https://shiny.posit.co/) or [RMarkdown
25 documents](https://rmarkdown.rstudio.com/index.html)) using renv and then
26 publish that content to Posit Connect. This is a supported pattern where
27 renv is used to manage the local project environment and then Posit Connect
28 recreates and manages the deployment environment.
29
30 ## Publishing from the RStudio IDE
31
32 The RStudio IDE includes a button for push-button deployment to Posit
33 Connect: ![RStudio IDE Publish Button](ide-publish.png)
34
35 When this option is used to deploy content to Posit Connect, a manifest file
36 is automatically generated and sent to Posit Connect describing the project
37 environment. This manifest file will reflect the project environment create and
38 managed by renv. The renv generated `.Rprofile` file should **not** be
39 included in deployments to Posit Connect.
40
41 ## Publishing programatically
42
43 When publishing content to Posit Connect programatically, it is necessary to
44 generate a manifest file describing the project environment. This can be done
45 with the `writeManifest()` function from the
46 [rsconnect](https://github.com/rstudio/rsconnect) package. When using renv,
47 the only thing that needs to be considered is that rsconnect should be
48 installed and executed from within the renv environment so that it recognizes
49 the local project library when generating the manifest file. As long as
50 rsconnect is run from within the renv created environment, it will capture
51 project dependencies from the local renv library. This can be accomplished by
52 opening the project in RStudio or by starting the R session from the project
53 root directory. The renv generated `.Rprofile` file should **not** be
54 included in deployments to Posit Connect.
55
56 ## A word about packrat
57
58 Posit Connect uses [packrat](https://rstudio.github.io/packrat/) to restore
59 project environments on the Posit Connect server. This should have no impact
60 on how the user develops content for Posit Connect. It is not necessary for
61 the user to use packrat instead of renv when developing content, as the
62 environment management tool used locally has no impact on the tools RStudio
63 Connect uses for environment management. Therefore, there should be no concerns
64 with using renv to develop content that will be deployed to Posit Connect.