Skip to content

Read administrator Posit Assistant installs only from posit-assistant-path, and let it win #18973

Description

@gtritchie

Current behavior

A session looks for an administrator-provided Posit Assistant in two ways, and neither is what administrators need:

Relevant code, all in src/cpp/session/modules/chat/ unless noted:

  • ChatInstallation.hpp: InstallSearchPaths (systemStorageDir, pinnedPath), plus the doc comments on InstallSearchPaths and locatePositAssistantInstallation(const InstallSearchPaths&).
  • ChatInstallation.cpp: positAssistantSearchPaths(), systemSlot(), legacySystemInstall(), rankedCandidates(), locatePositAssistantInstallation(const InstallSearchPaths&), userInstallWouldBeSelected(const InstallSearchPaths&, ...).
  • src/cpp/session/modules/SessionChat.cpp: the "installation not found" messages, which name <systemConfigDir>/pai/bin or the pinned path.
  • src/cpp/session/session-options.json: the posit-assistant-path description.
  • src/cpp/session/include/session/SessionModuleContext.hpp: the comment on isPositAssistantInstallationEnabledByAdmin().

Expected behavior

An administrator-provided installation exists only when an administrator configures one with posit-assistant-path. When they do, it always runs.

When posit-assistant-path is unset

<systemConfigDir>/pai is not read at all: not its versions/, selected.json, or bin/. The only sources are:

  1. the user's slots (<userDataDir>/pai/versions via <userDataDir>/pai/selected.json), skipped when user installation is disabled (posit-assistant-installation-enabled=0 / RSTUDIO_DISABLE_POSIT_ASSISTANT_INSTALLATION);
  2. the bundled copy (only Workbench ships one; open-source Server, Desktop and Desktop Pro do not).

They compete under the existing #18774 rules: a compatible protocol first, then the highest version, with ties going to the user's copy.

Desktop doesn't read rsession.conf, so on Desktop the option is never set, and there is no bundled copy there. Desktop therefore runs only the user's own copy. That needs no Desktop-specific code; it follows from the rules above.

When posit-assistant-path is set to a directory P

P supplies the administrator's candidates:

  • Slots: P/versions/<slot>, resolved with selector::resolveSlot(P, kProtocolVersion, SelectorRepair::Disabled). The slot named by P/selected.json is used when it verifies. Otherwise the newest verifying slot for this protocol is used, and P/selected.json is never written.
  • P itself as a single installation directory (the directory containing dist, checked with verifyInstallDir()). This keeps 2026.09 configurations working. P/bin is not read.

If both exist, they compete with each other under the #18774 rules (compatible protocol, then version; ties go to the slot).

If P contributes a candidate, the best one runs. Nothing else is considered. It beats the user's copy and the bundled copy whatever their versions, which lets an administrator hold users on a version older than the bundled one. The user's copy is ignored (not removed) even when user installation is enabled; keep the existing once-per-session warning when one exists. If the administrator's copy declares a different protocol, it still runs, and the session reports the protocol mismatch as it does for any incompatible install. It does not fall back to another copy.

When P holds no valid installation

P holds no valid installation when it contributes no candidate: it doesn't exist, is empty, or contains neither a verifying slot for this build's protocol nor a directory that passes verifyInstallDir(). (An empty option value means the option is unset.)

  • The bundled copy is not considered. A typo or an unmounted share must not quietly run whatever version shipped with Workbench.
  • The user's slot is still used when user installation is enabled (as UsesUserSlotWhenPinnedPathIsInvalid asserts today): the user's own install is not a silent downgrade.
  • Log a warning once per session naming P.
  • Otherwise Posit Assistant is reported as not installed.

Update and reinstall offers

userInstallWouldBeSelected() returns false whenever P contributes a candidate (the user's install could never run). When P is invalid, it is true if user installation is enabled. When P is unset, the user's install competes against the bundled copy as today.

"Installation not found" messages (SessionChat.cpp)

These can no longer point at <systemConfigDir>/pai/bin:

  • P set: name P as the expected location, in both the managed and the unmanaged message.
  • P unset, installation managed: say installation is managed by the administrator and none has been configured. Don't name a path.
  • P unset, installation enabled: tell the user to install it from the Posit Assistant pane. Drop the "or have an administrator install it at …" clause.

Compatibility

This drops the default location that 2026.09 and earlier read. Both of these need a NEWS entry:

  • Server administrators who populated /etc/rstudio/pai/bin must set posit-assistant-path=/etc/rstudio/pai/bin, which is the unversioned-directory form. Pointing it at /etc/rstudio/pai reads slots under /etc/rstudio/pai/versions instead.
  • Desktop no longer reads an administrator-provided copy from <systemConfigDir>/pai. Users install their own.

Implementation notes

  • Replace InstallSearchPaths::systemStorageDir and pinnedPath with a single administrator directory (P, empty when unset). Don't keep the old fields alongside it. systemSlot() and legacySystemInstall() become the slot and unversioned lookups against P.
  • rankedCandidates() / locatePositAssistantInstallation(): when P is set, return the best of P's candidates, or fall through to the user slot alone. When it is unset, rank the user slot against the bundled copy. Update the "No valid AI installation found" debug listing to match.
  • Remove anything left unused. For example, check whether kLegacyInstallDirName is still needed outside the test that asserts the user's legacy pai/bin is never read.
  • Rewrite the doc comments on InstallSearchPaths, locatePositAssistantInstallation(), rankedCandidates(), and isPositAssistantInstallationEnabledByAdmin() (which says a disabled install uses "only an administrator-managed installation"; it can also be the bundled copy).
  • session-options.json: rewrite the posit-assistant-path description. It is the directory holding the administrator-provided Posit Assistant, either versioned installs under versions selected by selected.json, or a single installation directory (the one containing dist). When it holds a valid installation, that installation is always used. Regenerate SessionOptions.gen.hpp.

Tests

ChatInstallationTests.cpp has many tests that stage installations in systemStorageDir or legacySystemDir(), or set pinnedPath. Each needs rewriting against P, or deleting where it covers behavior that no longer exists (a default-location copy competing by version):

FallsBackToSystemSlot, FallsBackToLegacySystemInstallation, FollowsTheSystemSelector, ResolvesAroundAStaleSystemSelectorWithoutRewritingIt, PrefersNewerSystemSlotOverStaleUserSlot, PrefersNewerLegacySystemOverStaleUserSlot, PrefersNewestInstallation, PrefersCompatibleProtocolOverHigherVersion, FallsBackToHighestVersionWhenNoneIsCompatible, TreatsMissingProtocolFileAsIncompatible, RanksVersionlessInstallationLowest, BreaksVersionTiesBySource, SkipsUserSlotsWhenInstallsAreManaged, PinnedInstallationWinsOverNewerUserSlot, UsesUserSlotWhenPinnedPathIsInvalid, SkipsReadOnlySourcesWhenSystemPathIsPinned, FindsPinnedInstallationWhenInstallsAreManaged, UserInstallWouldBeSelectedOverVersionlessReadOnlyInstall, UserInstallWouldNotBeSelectedBelowNewerSystemSlot, UserInstallWouldNotBeSelectedUnderValidPinnedPath, ChatInstallation.BundledPathSkipsIncompleteBinSubdirectory, ChatInstallationHeld.DoesNotRunUserSlotForReadOnlyCopies, ChatInstallationHeld.ReportsNothingForALegacyInstallWithoutProtocol.

ChatStaticFilesTests.cpp sets pinnedPath to serve one installation (ChatStaticFilesResolution::serve() and ServesFromTheHeldInstallationUntilItIsCleared). Switch these to P as an unversioned directory.

Cases the suite must cover:

  • P unset: copies at the default <systemConfigDir>/pai (slots and bin/) are never used, even when nothing else exists; the user slot and the bundled copy compete by version, with ties going to the user.
  • A slot under P selected by P/selected.json resolves; a stale or unusable selection falls back to the newest verifying slot without rewriting P/selected.json.
  • P itself as a 2026.09-style unversioned install resolves; P/bin is not read.
  • P holding both a slot and an unversioned install: the higher compatible version wins, and on a tie the slot wins.
  • A valid P beats a newer compatible bundled copy and a newer user slot, with user installation enabled or disabled.
  • A valid P whose only candidate has a mismatched protocol still runs rather than falling back.
  • P nonexistent, empty, or holding only slots for another protocol: bundled is not used; the user slot is used when enabled; nothing resolves when user installation is disabled.
  • userInstallWouldBeSelected(): false under a valid P regardless of version; true when P is invalid and installation is enabled; false when installation is disabled; ranked against bundled when P is unset.

Docs

Verification

Build, then run the chat unit tests, for example as #18892 did:

GTEST_FILTER='Chat*' ./build/src/cpp/rstudio-tests --scope rsession

Activity

  1. self-assigned this
    on Sep 28, 2026
  2. added theissue type on Sep 28, 2026
  3. changed the title [-]posit-assistant-path should relocate the administrator's Posit Assistant slots, not pin one install[/-] [+]Read administrator Posit Assistant installs only from posit-assistant-path, and let it win[/+] on Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions