Skip to content

Commit 07b3cb1

Browse files
committed
Default rig to user mode in configure-test-env.ps1 (#15327)
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. (cherry picked from commit 1ad9b3d)
1 parent a7198d0 commit 07b3cb1

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎tests/configure-test-env.ps1‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ try { $null = gcm rig -ea stop; $rig=$true } catch {
55
}
66

77
If ($rig) {
8+
# rig defaults to admin mode, where installing R raises a UAC prompt. User
9+
# mode installs R in the user profile instead; an explicit RIG_MODE wins.
10+
# The variable is removed again at the end so it does not leak into a
11+
# dot-sourcing shell. rig.exe does not need the mode later: rvenv.cfg
12+
# records the absolute path of the R it selected.
13+
$rigModeWasSet = [bool]$env:RIG_MODE
14+
If (-not $rigModeWasSet) { $env:RIG_MODE = 'user' }
815
# In admin mode rig proj sync installs a missing R by re-running itself
916
# elevated, which leaves the project library owned by the admin account.
1017
# Install R separately (rig add does nothing when it is already installed),
@@ -31,6 +38,7 @@ If ($rig) {
3138
}
3239
}
3340
}
41+
If (-not $rigModeWasSet) { Remove-Item Env:RIG_MODE }
3442
}
3543

3644
# Check python test environment ---

0 commit comments

Comments
 (0)