Understanding Packages During Deployment#
Posit Connect will re-create your R or Python package environment upon deploy to match the environment you deployed from.
When you deploy content to Posit Connect, the deployment process creates a content bundle, which includes your code and data files, as well as a list of the packages and the versions of R and/or Python your content uses. For R and sometimes for Python, the exact package versions and where they were installed from is also included.
In most cases, the package and language information in the bundle is captured
automatically by the deployment process, but you will have to explicitly
capture it if you are using Git-backed publishing or trying to
rsconnect deploy manifest command.
When the content item is deployed, Posit Connect creates a standalone environment for your content to run. In this environment, Posit Connect examines the information in the bundle, matches the version of R or Python, and downloads and installs the packages that are documented.
Matching Language Versions
Posit Connect automatically matches the version of R and/or Python documented in the bundle to the versions available on Posit Connect.
By default, Posit Connect does not require exact language version matching, though this is configurable. Posit Connect uses the closest version of R and any Python version within the same major release. This can occasionally cause version mismatch problems. We recommend having the same versions of R and Python on Posit Connect that you are using to develop your content.
Since Posit Connect creates its own package environment, it must be able to find and install any private packages you're using in your content.
Unless you are including the code from your package in the content bundle, they must be available in a location Posit Connect can also reach like GitHub or a Posit Package Manager repository.
In most cases, Posit Connect will install R and Python packages from the same location you installed them from when developing.
Overriding Manifest Repositories
A Posit Connect administrator can override the R or Python repositories that appear in the manifest for a content item. They may do this, for example, to ensure that all installs come from a sanctioned internal repository. If you're seeing packages install from an unexpected location, this is probably why.
Why can't I just directly upload my package environment to Posit Connect?#
R and Python package installs work properly only with the right operating system and the right versions of R or Python. The only way for Posit Connect to ensure the package environment will function is to download and install the packages itself for the proper version of R or Python and the proper operating system.
What if my content relies on system packages?#
Some R and Python packages rely on system libraries to operate. Some common examples include libraries for creating PDFs using R Markdown or Quarto, system libraries for working with geospatial data, and invoking Java using the rJava library.
Posit Connect cannot automatically download and install these system libraries.
If you are creating content that requires these system libraries, a system administrator will have to install them in the environment where Posit Connect runs.
How does the bundle know which packages I need?#
If you are automatically creating the bundle, the creation process scans your code for package dependencies, determines which version of those packages is available in your package library, and documents those versions inside the bundle.
Standard ways of invoking packages in R or Python will be recognized.
Some valid package invocations Posit Connect will recognize in R:
library(pkg) require(pkg) pkg::function(...)
In Python, a
requirements.txt file communicates package requirements. When
requirements.txt file is not present, requirements are captured with a
pip freeze. Standard
import pkg statements should be used.