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
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:
Make sure that the “CRAN” repository is selected in the dropdown of repositories you can install from, and click on the “Setup” button
Choose Linux as the operating system, Ubuntu 24.04 (Noble) as the distribution, and choose “No” under “Snapshots”
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/rsession.conffile in your terminal.Restart Workbench to apply the changes
Go to the user interface of Workbench (click on the “Workbench” tab), log in using (
positas the username and the password), and an RStudio session will launch in WorkbenchAt the R console, install a package (for instance
dplyr). 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/dplyr_1.2.1.tar.gz' .... * installing *binary* package ‘dplyr’ ... * package ‘dplyr’ successfully unpacked and SHA256 sums checked * DONE (dplyr) ....
Configuring for Python
To configure Workbench for Python, here we are going to configure uv to use your Package Manager instance as the default PyPI repository. The configuration is done in the /etc/uv/uv.toml file. Note that you can use the same approach to configure pip directly. The documentation for both is available in Configuring Posit Workbench guide.
Create and edit the /etc/uv/uv.toml file to include the following:
/etc/uv/uv.toml
[[index]]
url = "https://<your-package-manager-url>/ppm/pypi/latest/simple"
default = trueTo test the Python configuration, open the terminal inside an 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.
# This should show that you are using your own instance of Package Manager.
uv pip install duckdb -vConfigure 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:
- Make sure that the “CRAN” repository is selected in the dropdown of repositories you can install from, and click on the “Setup” button
- Choose Linux as the operating system, Ubuntu 24.04 (Noble) as the distribution, and choose “No” under “Snapshots”
- 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.gcfgfile in your terminal. - Restart Connect to apply the changes
Connect for Python
Connect uses uv by default for package installation for all Python-based content. uv reads the /etc/uv/uv.toml file to control the Python repository used to retrieve packages, so your configuration changes need to happen there. Instructions for this change are in the Connect Python Package Management guide, and are the same as for Workbench.
For this lab, the three products are running on the same server, so you already edited the /etc/uv/uv.toml file to point at your Package Manager instance when configuring Workbench for Python. In production environments, we do not recommend running Connect on the same server as Workbench and Package Manager. If you are running Connect on a different server, you will need to make the same change there.
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:
- Go to the user interface of Connect (click on the “Connect” tab), log in using (
positas the username and the password), click on the “Publish” button, and select “Import from Git” - In the “Git Repository URL” field, enter the following URL:
https://github.com/fmichonneau/lorenz-atlas - Choose the
mainbranch - Leave
[root directory]as the directory containing themanifest.jsonfile, and enter a title for the content. - 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.
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:
- Go to the user interface of Connect (click on the “Connect” tab), log in using (
positas the username and the password), click on the “Publish” button, and select “Import from Git” - In the “Git Repository URL” field, enter the following URL:
https://github.com/fmichonneau/lissajous-shiny-python - Choose the
mainbranch - Leave
[root directory]as the directory containing themanifest.jsonfile, and enter a title for the content. - 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: Workbench R uses an OS-specific binary URL, Workbench Python sets the session package index, Connect R overrides its CRAN repository (include internal repositories such as
git), and Connect Python is set in/etc/uv/uv.toml. - 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.