Lab 5 – Setting up Repositories and deploying content to Connect
The developers of the content that will be deployed on Connect, whether they use R or Python, rely on packages and libraries that are distributed by repositories such as CRAN and PyPi respectively. As an Administrator of Connect you can configure the repositories used and other factors such as the format (source or binary) in which the packages will be downloaded.
- Reading time: 10 minutes
- Documentation reading time: 35-45 minutes
- Hands-on exercise time: 20-30 minutes
R package management
When developing content in R, developers rely on packages. These packages are hosted in repositories. The most popular repository is called CRAN and there are multiple mirrors hosting its content. Another popular repository is Bioconductor. Additionally, enterprises might host their own repositories with private packages or approved subsets of CRAN for instance. When developers deploy content to Connect, the repositories used to download the packages is recorded and uploaded to Connect.
However, as an administrator you can configure the Connect server to complement the repositories used by the developers or to ignore them.
- By setting
R.PackageRepositoryResolution = "lax", the list of repositories used by the developer and the list from the Connect configuration file are merged, with the list from the Connect configuration taking precedence. - By setting
R.PackageRepositoryResolution = "strict", the list of repositories used by the developer is ignored, and only repositories listed in the Connect configuration file are used. To make sure that content deploy successfully when using this setting, your developers need to use the same repositories in their development environment. This setting is only recommended in security conscious environments.
Posit Package Manager is a repository management solution that makes it easy to centralize the management of the R packages and Python libraries used by your developers. Posit Package Manager integrates with Connect. There is a publicly available version of Package Manager that you can use. If you purchase a license for Package Manager, you can have an offline version of CRAN (useful for air gapped environments), curate the list of approved packages in your organization, and host private packages. Both build binary versions of the R packages for Linux distributions speeding up content deployment as packages do not need to be compiled during deployment. Connect provides options to control the installation of binary versions of the packages.
For this lab, you are going to configure Connect to use the public version of Posit Package Manager as the “CRAN” repository to serve binary versions of the R packages. With this setting, your deployments will be fast as the packages won’t need to be compiled, but if your developers used repositories outside of CRAN for their development, the deployment will still succeed.
Based on your reading of the documentation, what do you need to add to your configuration file?
- Go to the Setup page of Package Manager
- Select “Linux” for the Operating System
- Choose “Ubuntu 24.04 (Noble)” for the Linux Distribution
- For Snapshots, choose “No, install the most recent package available”
- Under Environment, choose “Posit Connect”
- Copy the configuration snippet under Setup Instructions
- Note that you installed many of the System Requirements listed at the bottom of the page.
- Open Connect’s configuration file (
/etc/rstudio-connect/rstudio-connect.gcfg) and Paste the configuration entry. - Restart Connect.
Python
Connect gives administrators control over how the Python environments are managed. The recommended approach is to use the PythonPackageRepository setting in rstudio-connect.gcfg to configure the repository used to download Python libraries. For instance, you can configure Connect to use the public version of Posit Package Manager as the repository for Python libraries using:
[PythonPackageRepository "PyPI"]
URL = https://packagemanager.posit.co/pypi/latest/simpleYou can instead use the URL for your own instance of Posit Package Manager if you have one. Note that this setting is only available with Connect 2026.05 and later.
After editing the configuration file, restart Connect.
Similarly to R, the Python.PackageRepositoryResolution setting controls whether the repositories used by the developers are used or ignored. The recommended setting is lax which merges the list of repositories used by the developers with the list from Connect’s configuration file, with Connect’s taking precedence. The other option strict ignores the repositories used by the developers and only uses the list from Connect’s configuration file. This setting is only recommended in security conscious environments.
While you can configure pip or uv at the system level (by editing /etc/pip.conf and /etc/uv.conf respectively), the configuration settings for the repository URL in Connect’s configuration take precedence over the system level configuration. Editing these files might however be useful if you need to configure additional settings such as timeouts or trusted hosts.
Deploying Content
You are now ready to deploy content to Connect. There are several ways of deploying Content, but for the purpose of this lab, we are going to use the Connect Gallery. The Gallery, introduced in Connect 2025.05, is a collection of assets that can be deployed on a Connect server. They are hosted on GitHub and do not require any coding or any set up. This provides an easy mechanism to make sure that your installation of Connect is ready to deploy content from your users.
Navigate to the “Posit Connect” tab, and click on “Log in”. You can log in as any one of the users listed previously that have at least Publisher privileges such as “elena.rodriguez” (as a reminder, their password is the same as their user name).
Deploying R Content
Once you are logged in, go to the “Gallery” tab within Connect. There, navigate to the “Examples” section, and click on the “Add” button for the “Quarto Stock Report using R”.
It takes a few minutes to deploy this content. You can check the logs for the deployment of this report by navigating to the “Content” link in the navigation bar. To see content that has not yet been published, you can type: “not:published” in the search bar. You should see an entry listed as “extension-XXXXXXXXXXX” in the list that appears. Click on that name. In the new page that appears, click on “Logs” in the top right corner. The deployment log for this application is then displayed, and you can check that Connect is correctly downloading the R binary packages from Package Manager.
Towards the beginning of the logs, you should see something like:
Packages will be installed using the following repositories:
- CRAN = "https://packagemanager.posit.co/cran/__linux__/noble/latest"
- CRAN.1 = "https://cloud.r-project.org"
indicating that the repository serving binary packages from Package Manager is configured correctly as it takes precedence on the CRAN repository configured in the source code of the content being deployed.
Additionally, when installing packages, you should see output indicating that binary packages are being installed (notice the word binary in the output):
Caching MASS.
Using cached MASS.
OK (downloaded binary)
Deploying Python Content
While the “Quarto Stock Report using R” is being deployed, you can deploy the “Quarto Stock Report using Python” in a similar way. Navigate to the “Gallery” tab within Connect. There, navigate to the “Examples” section, and click on the “Add” button for the “Quarto Stock Report using Python”.
Similarly, to see the logs during the deployment, navigate to the “Content” link in the navigation bar. To see content that has not yet been published, you can type: “not:published” in the search bar. You should see an entry listed as “extension-XXXXXXXXXXX” in the list that appears (the Python should be the first one in the list). Click on that name. In the new page that appears, click on “Logs” in the top right corner. The deployment log for this application is then displayed, and you can check that Connect is correctly downloading the Python libraries from Package Manager.
Towards the beginning of the logs, you should see something like:
Received repositories from Connect's configuration:
- PyPI = "https://packagemanager.posit.co/pypi/latest/simple
indicating that the repository serving Python libraries from Package Manager is configured correctly.
Once all the report is successfully deployed, you can click the “Check” button to verify that you completed all the steps for this lab.
Check Your Understanding
After completing this lab, you should be able to answer the following questions:
Repository Configuration: What is the difference between setting
R.PackageRepositoryResolution = "lax"versusR.PackageRepositoryResolution = "strict"in Connect’s configuration? When would you use each setting?Package Manager Integration: What are the main benefits of using Posit Package Manager with Connect, and how does the
R.PositPackageManagerURLRewriting = "force-binary"setting improve deployment performance?
Looking back, Planning ahead
Based on what you learned, ask your team:
- Which repositories do you want to enable in Connect for R and Python?