From 03e6424f28ff2abda2b43c00de6ce52fdbbeed8d Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Tue, 10 Nov 2026 12:35:41 +0100 Subject: [PATCH] Default rig to user mode in configure-test-env.ps1 rig defaults to admin mode, where installing R elevates and raises a UAC prompt on every setup run on Windows. User mode installs R in the user profile without elevation, which is also what the rig maintainer recommends for `rig proj` (r-lib/rig#503). The script sets RIG_MODE=user only when it is unset, so an explicit RIG_MODE or a rig config still wins, and removes it again at the end so dot-sourcing the script does not change the caller's shell. The selected R is recorded as an absolute path in `.rvenv/rvenv.cfg`, so the tests do not need the variable. Only the PowerShell script changes. On Linux, user mode installs portable R builds that rig documents as less tested than the distro builds. Checked on Windows: with RIG_MODE unset the script selects R 4.6.2 under %APPDATA%\rig\data\r, syncs the lock and installs dev knitr and rmarkdown, and leaves RIG_MODE unset in the calling shell. A knitr smoke-all document passes with and without RIG_MODE=user. --- tests/configure-test-env.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/configure-test-env.ps1 b/tests/configure-test-env.ps1 index 18a434f14da..f329bf797b9 100644 --- a/tests/configure-test-env.ps1 +++ b/tests/configure-test-env.ps1 @@ -5,6 +5,13 @@ try { $null = gcm rig -ea stop; $rig=$true } catch { } If ($rig) { + # rig defaults to admin mode, where installing R raises a UAC prompt. User + # mode installs R in the user profile instead; an explicit RIG_MODE wins. + # The variable is removed again at the end so it does not leak into a + # dot-sourcing shell. rig.exe does not need the mode later: rvenv.cfg + # records the absolute path of the R it selected. + $rigModeWasSet = [bool]$env:RIG_MODE + If (-not $rigModeWasSet) { $env:RIG_MODE = 'user' } # In admin mode rig proj sync installs a missing R by re-running itself # elevated, which leaves the project library owned by the admin account. # Install R separately (rig add does nothing when it is already installed), @@ -31,6 +38,7 @@ If ($rig) { } } } + If (-not $rigModeWasSet) { Remove-Item Env:RIG_MODE } } # Check python test environment ---