Skip to content

Skip alias links outside the R root on Windows - #507

Merged
gaborcsardi merged 4 commits into
r-lib:mainfrom
kevinushey:bugfix/windows-alias-outside-root
Nov 7, 2026
Merged

gaborcsardi merged 4 commits into
r-lib:mainfrom
kevinushey:bugfix/windows-alias-outside-root

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Fixes #506.

On Windows in user mode, find_aliases() failed the whole command when an R-release.exe/R-oldrel.exe/R-next.exe link pointed at an R outside the current root, because find_r_version_in_link() bailed when the target did not start with get_r_root() plus a backslash. That took down rig list, rig add's already-installed check, and rig system make-links whenever RIG_R_INSTALL_DIR (or r-install-dir) named another root than the one the existing links were made for, and also when it named the same root with forward slashes.

find_r_version_in_link() now returns Option<String>, with None for a file that is not a rig link or whose target is not under the root, and both callers skip such a link, as the macOS and Linux find_aliases() already do. rig system make-links leaves the link alone rather than deleting it as unused, since it belongs to another root. The version parsing moved into two pure helpers, user_version_from_link_target() and admin_version_from_link_target(), with unit tests covering the root-prefix match (including case, forward slashes, a different root, and a root that is a prefix of another directory name) and the admin-mode R-<version>/R-devel/x86_64-on-aarch64 cases.

Checked with cargo fmt --check. The two helpers and their tests are plain string code, so I ran them natively on macOS as a standalone rustc --test build (both pass); the Windows build itself, and the tests inside src/windows/mod.rs, are left to the Windows CI job, which is why this starts as a draft.

In user mode, find_aliases() failed the whole command when an
R-release.exe/R-oldrel.exe/R-next.exe link pointed at an R outside the
current root, which happens after an install into another
RIG_R_INSTALL_DIR, or when that variable names the same root with
forward slashes. Such a link is now skipped, as on macOS and Linux, and
rig system make-links leaves it alone. The version parsing moved into
two pure helpers with unit tests.

Fixes r-lib#506.
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.48%. Comparing base (5230497) to head (4b38e0f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #507   +/-   ##
=======================================
  Coverage   65.48%   65.48%           
=======================================
  Files          91       91           
  Lines       47600    47611   +11     
=======================================
+ Hits        31169    31180   +11     
  Misses      16431    16431           

☔ 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.

@kevinushey
kevinushey marked this pull request as ready for review November 6, 2026 20:26
@kevinushey

Copy link
Copy Markdown
Contributor Author

The six redhat/ubi* failures are unrelated to this change; they are the fork-PR limitation of the Linux container tests.

Those jobs pass secrets.REDHAT_ORG and the REDHAT_ACTIVATION_KEY_RHEL* secrets into the container (the ENVS block in the Makefile), and tests/test-linux-docker.sh runs subscription-manager register --org ${REDHAT_ORG} --activationkey ... under set -e before any test. GitHub does not give a pull_request run from a fork access to repository secrets, so all of them are empty here (the job log shows -e REDHAT_ORG_RHEL7= -e REDHAT_ORG_RHEL8= ...), the command becomes --org --activationkey, and the script stops with subscription-manager: error: argument --org: expected one argument without running anything.

The same six jobs failed the same way on #490 and #492, both fork PRs, and they pass on main and on in-repo branches (today's fix/admin-mode-install-noroot run, for example). This change only touches src/windows/mod.rs, and the Windows jobs are all green: Build with Rust 1.92.0 (windows-2022), Windows, Windows (user mode), Windows aarch64, Windows aarch64 (user mode), and the x86_64-on-aarch64 build, which is where the new unit tests run.

If it's useful, the matrix setup step could drop redhat/* from make print-linux-variants-json when REDHAT_ORG is empty, so fork PRs don't show these as failures; happy to send that separately.

gaborcsardi and others added 3 commits November 7, 2026 13:09
This is pretty niche currently, no need for a long NEWS.md entry.
On Windows, an R-release.exe, R-oldrel.exe or R-next.exe link that
points outside the R installation directory is skipped. Warn about it,
once per link per run, so a missing alias in `rig list` is not a
mystery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@gaborcsardi

Copy link
Copy Markdown
Member

Thanks!

@gaborcsardi
gaborcsardi merged commit 906a725 into r-lib:main Nov 7, 2026
52 of 58 checks passed
ronblum added a commit to rstudio/rstudio that referenced this pull request Nov 10, 2026
rig's own fix (r-lib/rig#507) converts the slashes itself; the package
bundles a rig build that includes it.
@github-actions

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 22, 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.

Windows user mode: an alias link outside the current R root makes rig add/list fail

2 participants