Repository navigation
Offer R install and switch choices with destination confirmation - #19158
Conversation
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
…nfirmation # Conflicts: # e2e/rstudio/tests/projects/renv_r_version_switch.test.ts # src/cpp/session/modules/SessionRig.R # src/cpp/session/modules/SessionRig.cpp # src/cpp/tests/testthat/test-rig.R
…nfirmation # Conflicts: # src/cpp/session/modules/SessionRig.R
… while pending - userInstallBegin's third positional parameter is launchctl, so the destination went there instead of 'directory' - the destination-specific lookup skipped the cache refresh that findInstalledRVersion used to do, so a reload offered the install again - editing the folder while the install request was pending re-enabled OK - fake-rig lifecycle tests now unset an inherited RIG_R_INSTALL_DIR - fold the NEWS entry into #12622's
Two sessions remembering different roots at once could each rewrite the file from a stale read and drop the other's entry.
gtritchie
left a comment
There was a problem hiding this comment.
Comments inline. None of them block merging. The closest to a bug is that the install is refused when the custom root can't be recorded (SessionRig.cpp:406); the rest are cleanup, one test gap, and one accessibility gap in the new dialog.
I checked that rig 0.11.0 respects RIG_R_INSTALL_DIR for rig system dirs and rig list, and that scanRoots matches its macOS user-mode layout. The which.max -> order() change in findInstalledRVersion is a real fix: which.max(package_version(...)) errors on R 4.3.3.
| if (error) | ||
| return error; | ||
|
|
||
| error = r::exec::RFunction(".rs.rig.rememberInstallDir") |
There was a problem hiding this comment.
If .rs.rig.rememberInstallDir fails (user data dir read-only, full, or with bad permissions), this returns the error and R isn't installed at all, even though the root is only being recorded for later discovery.
Recording it before the job starts makes sense, since on macOS rig can outlive a session that crashes mid-install. But a failure here should be logged (LOG_ERROR) and the install should go ahead.
There was a problem hiding this comment.
Agreed. Fixed in 4663580: a failure to record the root is logged and the install goes ahead. The job still finds the new R by scanning the confirmed directory, so only later discovery would be affected.
| #' Without rig (a damaged installation), use the explicit environment | ||
| #' override or its platform default. The confirmed path is always passed to | ||
| #' rig. | ||
| .rs.addFunction("rig.defaultInstallDir", function(rig = .rs.rig.find(), |
There was a problem hiding this comment.
When rig isn't found, this falls back to copies of rig's per-platform default roots so the dialog still has a folder to show. But RInstallJob::initialize resolves rig with the same .rs.rig.find() and fails with "rig was not found" whatever folder is chosen, so the user confirms a dialog for an install that can't run.
Simpler: have rig_get_install_dir return a "rig was not found" error when .rs.rig.find() is empty, and drop the override/APPDATA/~/.local/share/rig/r fallback and its test. That also removes a copy of rig's defaults that could drift from rig's own.
There was a problem hiding this comment.
Done in 4663580. .rs.rig.defaultInstallDir now errors with "rig was not found" when rig is absent (the client shows that in an error dialog), and the platform-default fallback and its test are gone.
| Error lookupError = findInstalledRVersion(version_, &installed); | ||
| // later checks this session (e.g. after a reload) reuse the cached | ||
| // list of installations, which must include the new R | ||
| Error refreshError = r::exec::RFunction(".rs.rInstallations.cached") |
There was a problem hiding this comment.
This relists every installation synchronously (rig list --admin, rig list --user, the platform scan, every remembered root), and installedRVersion then scans the destination again. Right after this, onRInstallCompleted calls switchToR, and a user-mode install is always orthogonal, so the session usually restarts and throws the refreshed list away.
Clearing the cache instead (.rs.rInstallationsCache$installed <- NULL) covers the reload case equally well, because rInstallations.cached() relists when it's NULL, and it does no work in the common case.
There was a problem hiding this comment.
Switched to clearing the cache (.rs.rInstallations.clearCache()) in 4663580; the next lookup relists.
| if (refreshError) | ||
| LOG_ERROR(refreshError); | ||
|
|
||
| Error lookupError = r::exec::RFunction(".rs.rig.installedRVersion") |
There was a problem hiding this comment.
This replaces the only call to the C++ findInstalledRVersion (defined further down in this file, declared in SessionRig.hpp:38). Nothing else in src/cpp calls it, so it can be removed along with its declaration.
There was a problem hiding this comment.
Removed in 4663580, along with the declaration in SessionRig.hpp. Pro only uses installInProgress() from that header.
| }) | ||
|
|
||
| #' Read the standard rig user-mode layouts at roots selected in RStudio. | ||
| .rs.addFunction("rInstallations.scanRoots", function(roots) |
There was a problem hiding this comment.
This re-derives rig's user-mode layout and repeats the row-building in rInstallations.scan. rig can list a custom root itself: with rig 0.11.0, RIG_R_INSTALL_DIR=<root> rig list --user --json lists that root's versions and skips the Current alias. That's the same pattern rig.userDirs uses.
The tradeoff is one rig run per remembered root on each listing, so this is a suggestion. If you keep the scan, sharing one row-builder with rInstallations.scan would remove the duplication.
There was a problem hiding this comment.
I kept the scan but took the second option: scan and scanRoots now share .rs.rInstallations.rows() (4663580). Running rig per remembered root would add a process per root to every listing, and the scan is also what keeps those roots visible when rig itself is missing.
|
|
||
| events.addHandler(ConsoleActivateEvent.TYPE, event -> activateConsole(event.getFocusWindow())); | ||
|
|
||
| events.addHandler(RenvRestorePromptEvent.TYPE, event -> |
There was a problem hiding this comment.
The renv restore prompt was handled in RenvRVersionManager (an eager singleton, RStudioGinModule.java:311). Here it moves into the Console presenter, which now depends on RenvConstants and builds renv::restore() itself, while the R-version notices still go through RenvConsoleNoticeEvent.
Keeping onRenvRestorePrompt in RenvRVersionManager and having it call showNotice(...) would leave Console handling only RenvConsoleNoticeEvent, with all the project-notice logic in one place.
There was a problem hiding this comment.
Moved back in a6f0e73: RenvRVersionManager handles RenvRestorePromptEvent and goes through showNotice, so Console only handles RenvConsoleNoticeEvent now.
|
|
||
| test_that("the default R install directory follows the platform and override", { | ||
|
|
||
| default <- function(...) .rs.rig.defaultInstallDir(rig = "", ...) |
There was a problem hiding this comment.
Every case passes rig = "", so only the fallback branch is tested. The branch that runs in practice (rig system dirs --user, checking r_root, erroring otherwise) isn't covered.
fakeRig in this file could cover a good r_root, an empty one, and rig exiting non-zero.
There was a problem hiding this comment.
Rewritten with fakeRig in 4663580: good r_root, the RIG_R_INSTALL_DIR override, empty r_root, rig exiting non-zero, and no rig.
|
|
||
| contents_ = new VerticalPanel(); | ||
| contents_.setWidth("440px"); | ||
| contents_.add(new Label(constants_.rInstallDescription(version))); |
There was a problem hiding this comment.
This description (installed in its own subfolder, RStudio restarts afterwards) isn't linked to the dialog, and focus goes straight to the folder field. A screen-reader user hears the title and "Install in:", but not that confirming will restart RStudio under a different R.
ModalDialogBase.setARIADescribedBy(Element) handles this. Keep the Label in a field and call setARIADescribedBy(description.getElement()). (.claude/CLAUDE.md: "New UI should be built to conform from the start.")
There was a problem hiding this comment.
Done in a6f0e73 with setARIADescribedBy(description.getElement()).
…the row builder Review follow-ups: a root that cannot be remembered no longer refuses the install; the default destination errors without rig instead of showing a folder the job could not use; the cache is cleared rather than relisted when a job finishes; the unused C++ findInstalledRVersion is removed; the scans share one row builder; and the default-directory test covers rig's own branch.
…nstall dialog for assistive tech
Intent
When a project requests R 4.5.3 but only R 4.5.2 is installed, the Console now offers both Install and Switch to R 4.5.3 and Switch to R 4.5.2. Choosing installation first opens a dialog where the user can confirm, edit, or browse for the installation folder. Cancel leaves the Console offer available and starts no installation.
Approach
Automated Tests
test-rig.Rsuite passes with four platform skips using a standalone source-backed harness.QA Notes
Verify an exact installed match, a missing patch with a nearby installed match, and a missing version without a nearby match. Check the installation dialog in light and dark themes, keyboard navigation, Browse, empty/invalid folders, cancellation, and installation into a custom folder containing spaces. After installation, confirm RStudio restarts with the requested R and can discover it again after a later restart.
Documentation
Added a release note in
NEWS.md. The dialog explains the per-user installation folder and the restart after installation; no separate guide changes are included.Checklist
NEWS.md.