Skip to content

undo rig's RSTUDIO_WHICH_R in the gui launchd session - #19347

Merged
kevinushey merged 1 commit into
mainfrom
bugfix/rig-launchctl-gui-domain
Oct 30, 2026
Merged

kevinushey merged 1 commit into
mainfrom
bugfix/rig-launchctl-gui-domain

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Addresses #19229.

Summary

#19230 undoes what a user-mode rig add does to the default R outside RStudio, including the RSTUDIO_WHICH_R that rig's LaunchAgent exports. That last part did nothing when RStudio was started outside the GUI login (from tmux, or over ssh): such a process is in a Background launchd session, and there launchctl getenv / setenv / unsetenv act on that session's environment, not the GUI session's. The snapshot and the restore both read "", saw no change, and left RSTUDIO_WHICH_R pointing at the newly installed R for every app opened from the Finder or the Dock, until logout. The job verbs (list, load, unload) were not affected: from a Background session they still reach the GUI session's agents.

The opt-in e2e had the same blind spot, so its check passed and its cleanup skipped the variable. A run under tmux left RSTUDIO_WHICH_R pointing into a deleted Playwright sandbox, after which open /Applications/RStudio.app failed with "An unknown error occurred." (spawnSync ... ENOENT in the debug log), while launching the binary directly still worked.

Changes

  • SessionRig.R: .rs.rig.launchctl runs getenv, setenv and unsetenv through launchctl asuser <uid> /bin/launchctl, which reaches the GUI session without privileges for one's own uid, and is the same session when RStudio already runs in it. The command-running code moved to .rs.rig.command.
  • test-rig.R: covers which verbs are routed through asuser, and that launchd's environment is left alone when the uid cannot be found.
  • renv_r_version_switch.test.ts: reads and restores RSTUDIO_WHICH_R through asuser too, so the check and the cleanup see the GUI session.

Testing

  • The opt-in e2e (PW_ALLOW_R_INSTALL=1 npm run test:desktop-dev -- tests/projects/renv_r_version_switch.test.ts -g "installs a missing R"), run under tmux: it fails with main's SessionRig.R (RSTUDIO_WHICH_R left at the sandbox's rig R) and passes with this change; in both runs the GUI session's environment was clean afterwards.
  • r-scope rig and linter tests.
  • Checked by hand that launchctl asuser $(id -u) /bin/launchctl getenv|setenv|unsetenv reads and changes the GUI session's environment from both a Background and an Aqua session.

An RStudio started outside the GUI login (from tmux, or over ssh) runs in
a Background launchd session, where 'launchctl getenv/setenv/unsetenv'
neither see nor change the RSTUDIO_WHICH_R that rig's agent exports to
the GUI session. Run them through 'launchctl asuser' instead.

Addresses #19229.
@kevinushey kevinushey added this to the 2026.11 (Montauk Daisy) milestone Oct 29, 2026
@github-actions

Copy link
Copy Markdown

RStudio E2E - all platforms

All tests passed!

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

Passed Failed Skipped Flaky
4605 0 230 0
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 4 0 16 0
✅ desktop-linux 1152 0 43 0
✅ desktop-macos 1158 0 38 0
✅ desktop-windows 1151 0 50 0
✅ server-linux 1092 0 51 0
✅ setup 48 0 32 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 5826abe850b01b08c3e132e723da31ecbe6c3fbb - Run #1817

@kevinushey
kevinushey merged commit 366ae28 into main Oct 30, 2026
45 checks passed
@kevinushey
kevinushey deleted the bugfix/rig-launchctl-gui-domain branch October 30, 2026 01:38
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