Skip to content

Installing R via rig from the project R-version warning makes it the default R outside RStudio #19229

Closed

Description

@kevinushey

Summary

When the project R-version warning bar (#12622, PR #18935) installs a missing R via the bundled rig, it runs rig add <version> --user. On a machine with no prior rig user-mode default, rig's add also calls set_default_if_none, which makes the new R the user's default R outside RStudio:

  • macOS: installs and loads ~/Library/LaunchAgents/io.r-lib.rig.rstudio-which-r.plist, which runs launchctl setenv RSTUDIO_WHICH_R <rig R> at every login. That overrides Desktop's own R lookup for every launch from the Dock/Finder, outlives RStudio, and clobbers a user's own launchctl setenv RSTUDIO_WHICH_R.
  • macOS/Linux: creates ~/.local/bin/R and ~/.local/bin/Rscript symlinks to the new R (shadowing e.g. Homebrew's R when ~/.local/bin is first on PATH), and points rig's Current/current link at it.
  • macOS/Linux: appends . "$HOME/.local/bin/rigenv" to .profile, .bash_profile, .bashrc, .zprofile and .zshrc whenever ~/.local/bin is not ahead of /usr/local/bin on rig's PATH.

The PR's intent was that a switch is not persisted on macOS/Linux (it lasts until RStudio quits), so none of this should happen. rig 0.11.0 has no flag or environment variable to opt out: the LaunchAgent is installed by rig default in user mode whenever /Applications/RStudio.app exists, and rig add sets a default when none exists yet.

Expected

Installing R from the warning bar should install that R and nothing else: no LaunchAgent, no R/Rscript quick links, no shell profile edits, no change to rig's user-mode default.

Plan

  • RStudio: run rig with ~/.local/bin first on its PATH (so it never edits shell profiles), snapshot rig's default-R artifacts before rig add and remove the ones the install created (LaunchAgent plus launchd RSTUDIO_WHICH_R, R/Rscript links, Current link).
  • rig: propose a rig add --no-default opt-out upstream and use it once a release bundles it.

Seen on a colleague's Mac after the switch installed R 4.3.3 (daily build with #18935).

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions