Lab 6: Integrating Workbench and Connect with Package Manager

By the end of this lab, you will be able to:

  • Configure Workbench to use Package Manager for R and Python
  • Verify that Workbench is using Package Manager for package installations
  • Configure Connect to use Package Manager for R and Python
NoteBefore You Begin

This lab puts into practice the concepts covered in Integrating Package Manager with Workbench and Connect. If you have not read it yet, review it first so the steps below make sense.

Configure Workbench to Use Package Manager for R and Python

Once Package Manager is appropriately configured, ensure that Workbench uses it for both R and Python rather than CRAN and PyPI. This provides the greatest level of control over which packages enter the environment and allows users to benefit from pre-compiled Linux binary packages in R.

Configuring for R

To configure Workbench for R, go to the user interface of your Package Manager instance (use the tab), then:

  1. Make sure that the “CRAN” repository is selected from the repositories you can install from, click on the “hamburger” menu in the top right, and click on “Setup”
  2. Under “Operating System”, choose “Linux”, and Under “Linux Distribution” select “Ubuntu 24.04 (Noble)”, and choose “No” under “Snapshots”
  3. Under “Environment”, click on “Posit Workbench”, and follow the instructions to configure Workbench to use Package Manager for R. This will involve editing the /etc/rstudio/repos.conf file in your terminal. (note that additional instructions, which are listed in the Setup instructions, are needed to configure Positron)
  4. Restart Workbench to apply the changes, and check the status of the service to make sure Workbench is running and ready.

Configuring for Python

To configure Workbench for Python, update the value of the session-python-index-url setting in rserver.conf. Workbench injects this value into every session as both the PIP_INDEX_URL and UV_INDEX_URL environment variables, so this single setting points both pip and uv at your Package Manager instance. This is the Workbench-native approach and is preferable to editing /etc/pip.conf or /etc/uv/uv.toml directly. The documentation is available in the Python Package Installation guide.

Edit /etc/rstudio/rserver.conf to replace the value of session-python-index-url with the URL of the PyPI repository hosted on your Package Manager instance, then restart Workbench:

/etc/rstudio/rserver.conf
session-python-index-url=https://<your-package-manager-url>/pypi/latest/simple

Testing your Workbench configuration for R

To test these changes, open a new RStudio session running in Workbench (start a new session so it picks up the new setting), and run the following commands:

  1. Go to the user interface of Workbench (click on the “Workbench” tab), log in using (posit as the username and the password), and launch an RStudio session

  2. At the R console, install a package (for instance remotes). Check the install logs to confirm that the package was installed from your Package Manager instance and using the binary version of the package. You should see something like this in the install logs:

    R Console
    ....
    trying URL 'https://<your-package-manager-url>/ppm/cran/__linux__/noble/latest/src/contrib/remotes_2.5.0.tar.gz'
    ....
    * installing *binary* package ‘remotes’ ...
    * package ‘remotes’ successfully unpacked and SHA256 sums checked
    * DONE (remotes)
    ....

Testing your Workbench configuration for Python

To test the Python configuration, open the terminal inside a new RStudio session running in Workbench, and run the following commands:

Terminal
mkdir ~/python-repo-test
cd ~/python-repo-test
uv init
uv venv
source .venv/bin/activate
# Install a package with verbose output so that you can review the PyPI repo being used.
uv pip install duckdb -v

The logs should show that you are using your own instance of Package Manager.

Configure Connect to Use Package Manager for R and Python

Connect for R

To configure Connect for R, go to the user interface of your Package Manager instance (use the tab at the top of the Instruqt interface), then:

  1. Make sure that the “CRAN” repository is selected among the repositories you can install from, click on the “hamburger” icon menu in the top right corner, and click on “Setup”
  2. Choose Linux as the operating system, Ubuntu 24.04 (Noble) as the distribution, and choose “No” under “Snapshots”
  3. Under “Environment”, click on “Posit Connect”, and follow the instructions to configure Connect to use Package Manager for R. This will involve editing the /etc/rstudio-connect/rstudio-connect.gcfg file in your terminal to replace the entry for CRAN with the URL of the CRAN repository hosted on your Package Manager instance.
  4. Restart Connect to apply the changes

Connect for Python

Connect 2026.05 introduced the PythonPackageRepository setting, which is used to configure Python repositories for both uv and pip. Instructions for this change are in the Connect Python Package Management guide.

You can follow the same steps as above for R, but instead of selecting the “CRAN” repository, select the “PyPI” repository and follow the instructions to configure Connect to use Package Manager for Python.

Edit the /etc/rstudio-connect/rstudio-connect.gcfg file to include the following:

/etc/rstudio-connect/rstudio-connect.gcfg
[PythonPackageRepository "PyPI"]
URL = https://<your-package-manager-url>/pypi/latest/simple

Make sure to restart Connect after applying the change.

Testing Connect for R

To test that Connect deployments use Package Manager for R, you are going to deploy a Quarto document hosted on GitHub:

  1. Go to the user interface of Connect (click on the “Connect” tab), log in using (posit as the username and the password), input an email address when asked (Connect is not configured here to send email, so the address you use will not receive any notifications)
  2. Click on the “Publish” button, and select “Import from Git”
  3. In the “Git Repository URL” field, enter the following URL: https://github.com/fmichonneau/lorenz-atlas
  4. Choose the main branch
  5. Leave [root directory] as the directory containing the manifest.json file, and enter a title for the content.
  6. Click on the “Deploy Content” button to deploy the content.

You can validate that the deployment is using Package Manager by checking the logs for the package installation. You should see that the packages are being installed from your Package Manager instance and using the binary versions of the packages

It takes about 2 minutes for the deployment to complete.

Testing Connect for Python

To test that Connect deployments use Package Manager for Python, you are going to deploy a Python-based content hosted on GitHub:

  1. Go to the user interface of Connect (click on the “Connect” tab), log in using (posit as the username and the password), click on the “Publish” button, and select “Import from Git”
  2. In the “Git Repository URL” field, enter the following URL: https://github.com/fmichonneau/lissajous-shiny-python
  3. Choose the main branch
  4. Leave [root directory] as the directory containing the manifest.json file, and enter a title for the content.
  5. Click on the “Deploy Content” button to deploy the content.

The deployment logs should show that the packages are being installed from your Package Manager instance.

  • Package Manager only delivers value once Workbench and Connect are pointed at it; by default R installs from CRAN and Python from PyPI, bypassing every control you configured.
  • Redirecting both products to Package Manager gives you governance (blocklist rules, curated sources, and vulnerability scanning all take effect) and performance (pre-built Linux binaries instead of slow source compilation).
  • Configuration is separate for each product and each language: R in Workbench R uses an OS-specific binary URL (r-cran-repos in repos.conf), Python in Workbench uses session-python-index-url in rserver.conf (which configures both pip and uv), to configure R repositories in Connect, you can override its CRAN repository in rstudio-connect.gcfg (include internal repositories such as git), and for Python Connect uses a [PythonPackageRepository "PyPI"] section in rstudio-connect.gcfg.
  • Confirm each integration by installing a package with verbose output and checking that it resolves through your Package Manager instance rather than CRAN or PyPI.