Skip to content

Add rig add --no-default and --without-path - #490

Merged
gaborcsardi merged 5 commits into
r-lib:mainfrom
kevinushey:feature/add-no-default
Oct 23, 2026
Merged

gaborcsardi merged 5 commits into
r-lib:mainfrom
kevinushey:feature/add-no-default

Conversation

@kevinushey

@kevinushey kevinushey commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

rig add makes the first R version it installs the default when no default is set yet (set_default_if_none). In user mode that does more than install R: it creates the R/Rscript quick links, and rig default registers the version with RStudio and Positron, which on macOS means installing and loading the io.r-lib.rig.rstudio-which-r LaunchAgent that runs launchctl setenv RSTUDIO_WHICH_R ... at every login.

RStudio now bundles rig and runs rig add <version> --user when a project asks for an R version that is not installed (rstudio/rstudio#19229). From RStudio's side the LaunchAgent is a problem: it outlives RStudio, overrides RStudio's own R selection for every launch from the Dock, and clobbers a user's own launchctl setenv RSTUDIO_WHICH_R. The quick links also shadow e.g. Homebrew's R in the user's shell. There is currently no way to ask rig to only install R.

This PR adds rig add --no-default, which skips set_default_if_none on all three platforms. On Linux the user-mode R/Rscript aliases are then refreshed only when a default exists (otherwise they would be dangling links into current/bin). On Windows maybe_update_registry_default already runs only when the R.exe shim exists, so nothing else changes there. rig default <version> still works afterwards for users who do want the default.

A second commit adds rig add --without-path. In user mode rig also puts its quick-link directory on the PATH when it is missing: a line in the shell startup files on macOS and Linux (check_local_bin_path), and the directory prepended to the user PATH in the registry on Windows (add_user_bin_to_path, from sc_system_make_links). That happens on every rig add, not only when a default is set, so --no-default leaves it in place; --without-path skips it. It is a process-wide switch set from the parsed add arguments, since the PATH is edited from helpers that take no arguments.

The help text (src/help/add.md, regenerated with make help) now says what setting the default and the PATH setup involve, and NEWS has an entry.

Verified: cargo build, cargo fmt --check, cargo test --bin rig (1116 passed, 11 ignored), including a parsing test for both flags. I have not run the bats integration tests.

Once a release includes this, RStudio will pass --no-default --without-path; until then it undoes the default-R setup after the install (rstudio/rstudio#19229).

`rig add` makes the first R version it installs the default when none is
set yet. In user mode that also creates the R and Rscript quick links and
registers the version with RStudio and Positron: on macOS it installs a
LaunchAgent that sets RSTUDIO_WHICH_R at login. A tool that runs rig to
install R, like RStudio (rstudio/rstudio#19229), wants R installed and
nothing else, so `--no-default` skips setting the default. On Linux the
user-mode R/Rscript aliases are then only refreshed when a default exists.
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.46809% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.52%. Comparing base (27a1a28) to head (6f700e7).

Files with missing lines Patch % Lines
src/linux.rs 0.00% 7 Missing ⚠️
src/utils.rs 50.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #490      +/-   ##
==========================================
+ Coverage   65.50%   65.52%   +0.01%     
==========================================
  Files          91       91              
  Lines       47030    47075      +45     
==========================================
+ Hits        30809    30844      +35     
- Misses      16221    16231      +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

In user mode rig puts its quick-link directory on the PATH when it is
missing: a line in the shell startup files on macOS and Linux, and the
directory prepended to the user PATH in the registry on Windows. That is
not part of setting the default, so `--no-default` leaves it in place;
`--without-path` skips it, for tools that install R through rig and do
not want the user's environment changed.
@kevinushey kevinushey changed the title Add rig add --no-default Add rig add --no-default and --without-path Oct 22, 2026
@gaborcsardi

Copy link
Copy Markdown
Member

Windows registry issue

There is a problem with this on Windows, where the registry management is quite messy. rig installs into a temporary dir first, and the registry will point there. Currently we create R.exe and update the (top level) registry to point there instead of the temporary dir. But with the PR and --no-default there is no R.exe (potentially) and then maybe_update_registry_default() does nothing and we are left with the registry pointing to a non-existent directory.

OTOH there are other issues with the registry, e.g. sub-keys are not updated correctly, and the uninstall entries should be removed, probably. So I'll leave all the windows registry stuff to another PR.

Docs and code style changes

Which is the right thing to do, I think, because for Positron we don't set a default (we can't, anyway), only the list of available versions which probably should be updated. I'll update the NEWS because it says that we leave the IDE settings alone, which is not entirely true.

I'll update some docs and code style and I can merge this, and then I'll have another PR to fix/improve the windows registry handling.

@gaborcsardi
gaborcsardi merged commit 30d13f1 into r-lib:main Oct 23, 2026
52 of 58 checks passed
@gaborcsardi

Copy link
Copy Markdown
Member

Thanks!

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this pull request.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants