Skip to content

Add package management RPC functions#1084

Merged
bricestacey merged 5 commits intomainfrom
move-packages-to-ark
Mar 6, 2026
Merged

Add package management RPC functions#1084
bricestacey merged 5 commits intomainfrom
move-packages-to-ark

Conversation

@bricestacey
Copy link
Contributor

@bricestacey bricestacey commented Mar 4, 2026

This PR is to move R code from Positron into Ark. This provides two key features:

  1. We can use the LanguageRuntimeSession.callMethod() function to execute this code and return the result.
  2. The code is guaranteed to be loaded and we therefore do not need to load it from Positron

Related tickets:
posit-dev/positron#12076
posit-dev/positron#11842

Add new RPC endpoints for the Positron packages pane:

  • pkg_install: Install packages via pak or base R
  • pkg_list: List installed packages with metadata
  • pkg_update_all: Update all outdated packages
  • pkg_uninstall: Remove packages and unload namespaces
  • pkg_search: Search CRAN for packages by name
  • pkg_search_versions: Get available versions for a package

Each function supports both pak and base methods to allow flexibility depending on user preference and environment.

Related Positron PR that consumes this change: posit-dev/positron#12280

Add new RPC endpoints for the Positron packages pane:
- `pkg_install`: Install packages via pak or base R
- `pkg_list`: List installed packages with metadata
- `pkg_update_all`: Update all outdated packages
- `pkg_uninstall`: Remove packages and unload namespaces
- `pkg_search`: Search CRAN for packages by name
- `pkg_search_versions`: Get available versions for a package

Each function supports both `pak` and `base` methods to allow
flexibility depending on user preference and environment.
Copy link
Contributor

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working great!

Before you merge this, can you add some comments to each of these new functions to note that they are for use in the Packages Pane with the RPackageManager? I don't want us to get confused in this file between .ps.rpc.install_packages and .ps.rpc.pkg_install. Or maybe add comments and make the prefix for each of these new functions .ps.rpc.pkg_pane_install() and similar? If you're up for pushing a change to both branches.

pkg_install, pkg_uninstall, and pkg_update_all are no longer used -
the Positron R extension now calls pak/base R functions directly via
execute() for better console output.
@bricestacey bricestacey force-pushed the move-packages-to-ark branch from 4d10e5f to 170d2dd Compare March 6, 2026 18:50
@bricestacey
Copy link
Contributor Author

The strategy changed, so I've removed the package mutation functions.

I also moved everything to its own file to keep it separate.

Positron will now use executeCode() to perform package mutation operations. This executes the code directly in the console. We want to execute a "user-friendly" line of code, not one of these functions as we have no intention of creating yet another API for managing packages. So that is your traditional install.packages() or pak::pkg_install().

For install/uninstall it's really just switching between base R and pak and that is now performed in Positron.

However, for pak's update all, we still need to call into Ark for .ps.rpc.pkg_outdated() and feed the results into the code fed to executeCode()...

Copy link
Contributor

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working beautifully! 🤩

@bricestacey bricestacey merged commit 367b989 into main Mar 6, 2026
8 checks passed
@bricestacey bricestacey deleted the move-packages-to-ark branch March 6, 2026 20:56
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants