Skip to content

undo rig's Windows default after a user-mode install as well - #19233

Merged
kevinushey merged 8 commits into
mainfrom
bugfix/rig-user-install-side-effects-windows
Oct 27, 2026
Merged

kevinushey merged 8 commits into
mainfrom
bugfix/rig-user-install-side-effects-windows

Conversation

@kevinushey

@kevinushey kevinushey commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses #19229. Follows #19230 (now merged), which undoes what rig's first user-mode install does to the user's environment on macOS and Linux and leaves Windows alone.

On Windows rig add --user does the same kind of thing: the first user-mode install writes R.exe, RS.exe and Rscript.exe default shims into %USERPROFILE%\.local\bin and sets the current-user R-core default (Current Version and InstallPath on HKCU\Software\R-core\R and R64, plus their WOW6432Node twins for x86_64 R on arm64), and every install prepends the quick-link directory to the user PATH in the registry. So the rig R becomes R in every new shell and the current user's registry default. RStudio persists its own switch on Windows, so this is about not changing things outside RStudio.

This PR extends the same snapshot/restore to Windows:

  • the default shims are handled like the macOS/Linux quick links (removed when the install created them);
  • the registry values are read before and after through new in-process routines, .rs.registryGetValue / .rs.registrySetValue / .rs.registryDeleteValue in SessionRUtil, backed by core::system::RegistryKey, which gains create, getValue, setValue and deleteValue on the wide-character registry API (so non-ASCII data round-trips, and REG_EXPAND_SZ data is read as stored rather than expanded). Afterwards, values rig added are removed and values it changed are set back; the user PATH only loses rig's entry (case-insensitive, trimmed, as rig matches it), so anything else that changed the PATH meanwhile survives, and a PATH that did not exist before goes away again rather than being left empty. Explorer is told the user environment changed (WM_SETTINGCHANGE), so shells opened afterwards see the restored PATH. A registry that cannot be read is noted in the job's log and the file cleanup still runs; a restore that fails stays in the snapshot file for the next session to retry, as on the other platforms;
  • what was reverted is listed in the install job's output, as on the other platforms.

Along the way: the liveness probe #19230 uses for another session's snapshot, tools::pskill(pid, 0), terminates the process on Windows whatever the signal (R's ps_kill calls TerminateProcess for any signal). It is replaced by .rs.isProcessRunning, backed by core::system::isProcessRunning, which is now declared for every platform with a Windows implementation (OpenProcess + GetExitCodeProcess, with an inaccessible process counting as running, like EPERM on POSIX).

No NEWS entry: the feature is unreleased.

Tests: test-rig.R gains cases with an in-memory registry standing in for the routines (shims plus registry default plus PATH entry reverted, pre-existing default restored, PATH-only cases including a differently-cased entry and other concurrent additions, unreadable and unwritable registry) and a probe test. rstudio-tests --scope r --filter 'rig|linter': 355 pass. The core suite gains a Windows RegistryKey round-trip test (UTF-8 and %VARS% kept as stored, kinds reported, not-found errors, non-string kinds refused) and an isProcessRunning test against a live, a terminated and a nonexistent pid; the POSIX suite passes locally (802).

The new C++ only compiles on Windows, so CI's Windows build and core tests are the check for it. The flow end to end through rig add --user is still unverified on Windows: the e2e install test from #19230 skips there, since its checks read rig's files under HOME. Remaining shell call-outs elsewhere are collected in #19285.

rig add --user makes the first R it installs the user-mode default: R and
Rscript quick links in ~/.local/bin, rig's Current link, and on macOS a
login LaunchAgent that sets RSTUDIO_WHICH_R for every GUI application. It
also appends to the shell startup files unless ~/.local/bin precedes
/usr/local/bin on its PATH. None of that should happen for an R installed
from the project R-version warning bar: run rig with ~/.local/bin first on
PATH, and remove the default-R files the install created once it exits,
restoring launchd's RSTUDIO_WHICH_R. Files that existed before are kept.

Also drops a stale duplicate of the #12622 NEWS entry.

Addresses #19229
… stays off

Opt-in (PW_ALLOW_R_INSTALL=1), as it downloads and installs a build of R
into the sandbox home. Creates rig's quick-link directory first: rig 0.11.0
fails outright in a home without one.

Addresses #19229
rig 0.11.0 fails outright with "No such file or directory" when ~/.local/bin does not exist yet (r-lib/rig#491), as on a fresh macOS account, so the warning-bar install could not work there. The e2e no longer creates the directory itself.

Addresses #19229.
On Windows, rig's first user-mode install writes R.exe, RS.exe and
Rscript.exe default shims, sets the current-user R-core default (Current
Version and InstallPath on the R and R64 keys, and their WOW6432Node
twins), and every install prepends the quick-link directory to the user
PATH in the registry. Snapshot those values through PowerShell before
rig add runs, and afterwards remove the shims and values rig added, set
back the ones it changed, and take only rig's entry out of the PATH.

Addresses #19229
@kevinushey kevinushey added this to the 2026.11 (Montauk Daisy) milestone Oct 22, 2026
PowerShell reads a BOM-less script in the system ANSI code page, so the
restore script now carries a UTF-8 byte order mark and the reader's output
is marked UTF-8. psQuote doubles the typographic single quotes PowerShell
also takes as delimiters, not only the ASCII apostrophe.

Also give .rs.rig.userDefaultPaths one branch per platform instead of a
shared macOS/Linux body.
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

#################### 100% pass rate

Passed Failed Skipped Flaky
3362 0 173 1
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 0 0 14 0
✅ desktop-linux 1110 0 43 0
✅ desktop-macos 1115 0 38 1
✅ desktop-windows 1109 0 50 0
✅ setup 28 0 28 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit 9af0a2c5b628720d1e393d2ce1a08fa704c211bf - Run #1738

Base automatically changed from bugfix/rig-user-install-side-effects to main October 26, 2026 17:48
…ll-side-effects-windows

# 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
The Windows registry values rig writes are now read and restored through
.rs.registryGetValue/SetValue/DeleteValue (SessionRUtil), backed by
core::system::RegistryKey, which gains create/getValue/setValue/deleteValue
on the wide-character registry API so non-ASCII data round-trips and
REG_EXPAND_SZ data is kept as stored. Explorer is told when the user
environment changed.

tools::pskill(pid, 0) terminates the process on Windows whatever the
signal, so the liveness probe is now .rs.isProcessRunning, backed by
core::system::isProcessRunning (declared for all platforms, with a Windows
implementation via OpenProcess + GetExitCodeProcess).

Addresses #19229.
MSVC reads "\x99Brien" as \x99B (C7744, escape sequence out of range).
@kevinushey
kevinushey merged commit dfc95c6 into main Oct 27, 2026
39 of 40 checks passed
@kevinushey
kevinushey deleted the bugfix/rig-user-install-side-effects-windows branch October 27, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant