Repository navigation
treat an empty PW_RSTUDIO_R_LIBS_USER as unset - #18390
Conversation
The consolidated Linux e2e workflow (#18360) sets PW_RSTUDIO_R_LIBS_USER: ${{ ... == 'true' && format(...) || '' }} intending the empty branch to mean "use the harness default". A GitHub Actions env: value of '' is exported as a defined empty string, so rLibsUserTemplate()'s `??` took it as an explicit override and the R_LIBS_USER template became "". R treats an empty R_LIBS_USER as unset and computes its HOME-relative default, so globalSetup installed REQUIRED_PACKAGES under the real HOME while the session under test -- whose HOME the desktop fixture redirects into the per-run sandbox -- resolved a different, empty library. That is the exact hazard this file's header comment describes. citations.test.ts "inserts an R Package citation" then failed both attempts on every affected engine (the five with preinstall_r_packages empty: ubuntu-22/24-x86_64/24-arm64/26, debian-13): the panel searches the session's installed packages, finds no knitr, and reports "No matching packages". Use || so an empty override falls back, and name the source of the resolved library in the prep log so a future mismatch is visible in the job output rather than only as a missing package.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Code review findingsActionable items from an automated multi-agent review. The fix itself is correct and verified: R's Important
Suggestions
Pre-existing, adjacent — not introduced by this PRFlagged because they sit in the same file and the same failure class. Out of scope to fix here.
Note on CIThe failing |
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
…ogging Follow-ups from the review on #18390, all in the file this PR already touches: - required-packages.txt was split on '\n' only, so a Windows checkout (core.autocrlf=true on the GHA runners) left a trailing '\r' on every line. '\r' is a line terminator for JS regex, so in /#.*$/ the '.' cannot cross it and '$' anchors past it -- no comment was ever stripped, and all six header lines were passed to install.packages() as package names. Every Windows shard has been printing "[r-libs] WARNING: failed to install: # R packages pre-installed ..." as a result, which made the one signal that would reveal a genuinely missing package permanent noise. - .expand_R_libs_env_var lives in base, not tools, and ':::' does not inherit, so tools:::.expand_R_libs_env_var errored on every call and the reduced gsub fallback ran unconditionally. It happens to agree with R for the %p / %v templates we actually use, so nothing was mis-expanded, but the documented path never executed and %U / %S / %%-escaping would have been wrong. The fallback now marks itself so a future regression is visible in the prep log. - The template and its provenance are logged before prepareRLibs()'s early returns, so a skip-prep run -- the configuration most likely to be pointed at the wrong library -- is no longer diagnostic-free. - The module header and the README entry for PW_RSTUDIO_R_LIBS_USER now state that an empty value is treated as unset.
The five engines with PPM binary coverage (ubuntu-22/24/26 x86_64, ubuntu-24 arm64, debian-13 arm64) left preinstall_r_packages empty, so globalSetup installed the 23-package REQUIRED_PACKAGES set into the harness-default library (~/.cache/rstudio-playwright) -- which is not in any workflow cache -- on every single run. Flipping the flag routes the install through os-e2e-deps into the job-level R-libs tree, which is cached (keyed on the manifest via -req<hash>), and points globalSetup at it via PW_RSTUDIO_R_LIBS_USER, so a warm run installs nothing. ubuntu-24-x86_64 and ubuntu-26-x86_64 also get explicit cache scopes (noble-amd64 / resolute-amd64): both used the legacy empty scope, i.e. one shared "Linux" key. Tolerable while the cache held only pak's DESCRIPTION deps, but with the full compiled package set in the tree, noble and resolute sharing a library is an ABI hazard -- whichever engine saved first on main would hand its binaries to the other, and the presence check would see them as installed. The new scopes start those two caches cold; they warm on the next main-scoped run. No heartbeat change: fedora/rocky raise it because a cache miss can source-compile at test time, but these engines install binaries in the deps step, outside the watchdog's scope.
…#18487) The Windows and macOS e2e workflows never passed install-required-packages to the os-e2e-deps action, so the harness's REQUIRED_PACKAGES set (DBI, shinytest2, rmarkdown, ...) was installed from cran.r-project.org at test time on every run: by globalSetup when it could, and by per-test ensurePackages self-healing when it could not. During a CRAN outage those installs hang mid-suite (s4_unloaded_package, shinytest2 in the pr-18449 all-platforms run) instead of failing fast. Pass install-required-packages to the deps action on every desktop engine, matching Linux (PR #18390), so the set is installed from PPM into the cached R library before tests and a warm cache installs nothing at all. The macOS workflows and the scheduled Windows autocomplete workflow also gain the PW_RSTUDIO_R_LIBS_USER wiring that points globalSetup at that same library (the main Windows workflow already had it). The Linux Server workflow deliberately keeps its own system-library seed: its sessions run as a per-run user, and tests that exercise uninstall flows (fortunes, DBI) cannot remove packages from a root-owned library.
…18489 commit 849c42d Author: Kevin Ushey <[email protected]> Date: Mon Aug 10 13:43:21 2026 -0700 keep tidyverse; add it to required-packages.txt Restores tidyverse in the e2e DESCRIPTION (dropped in the previous review commit) and adds it to required-packages.txt, so globalSetup's presence check covers it and CI preinstalls it into the cached library. commit 5bd28d4 Merge: 0e36677 aebb191 Author: Kevin Ushey <[email protected]> Date: Mon Aug 10 13:42:52 2026 -0700 Merge remote-tracking branch 'origin/main' into test/e2e-rlibs-consolidation # Conflicts: # .github/actions/os-e2e-deps/action.yml commit 0e36677 Author: Kevin Ushey <[email protected]> Date: Mon Aug 10 13:32:26 2026 -0700 address review feedback - scope the provision-step chown to the resolved USER_LIB rather than a hardcoded ~/R, so the guard and the ownership handover stay in lockstep - fail the provision step with names when required packages are missing from the test user library, instead of echoing an unasserted count - pin the action's install step to R_LIBS_USER = the r-libs-user input, so the install can't diverge from the cache path and exported lookup - drop tidyverse from e2e/rstudio/DESCRIPTION (referenced by no test; the components tests use come via required-packages.txt) commit 6d2dcf3 Author: Kevin Ushey <[email protected]> Date: Fri Aug 7 17:10:38 2026 -0700 e2e: consolidate R package provisioning in the os-e2e-deps action Getting the harness's required R packages installed where the session can see them previously took a hand-wired pair in every workflow -- the install-required-packages input plus a PW_RSTUDIO_R_LIBS_USER env var pointing at the same path -- and configuring one without the other silently degraded to test-time installs from cran.r-project.org (the failure class behind #18390 and the pr-18449 Windows CRAN-outage hangs). The Linux Server workflow had a third mechanism: a separately curated list seeded into a root-owned system library, which uninstall-flow tests could never touch. Make the os-e2e-deps action own the whole contract: default install-required-packages to true and export PW_RSTUDIO_R_LIBS_USER from the action itself (skipped when the caller defines it or opts out), then delete the per-workflow wiring on Windows, macOS, and Linux desktop. The Linux engines keep their per-engine escape hatch (an empty value still opts out). The server workflow now copies the action-populated library into the per-run test user's default user library (~/R/%p-library/%v) and chowns it: rserver rebuilds each session's environment from scratch (#18348), so only R's own default path can reach the rsessions. Sessions get every package read-write, so uninstall-flow tests (missing_packages_banner) keep working, and the system-library seed is retired. Of its curated list, readr is genuinely used (import_dataset.test.ts) and moves into required-packages.txt; tidyverse is referenced by no test and is dropped. Addresses #18488. commit 02d8c6e Author: Kevin Ushey <[email protected]> Date: Fri Aug 7 16:41:44 2026 -0700 e2e: pre-install required R packages on the windows and macos runners The Windows and macOS e2e workflows never passed install-required-packages to the os-e2e-deps action, so the harness's REQUIRED_PACKAGES set (DBI, shinytest2, rmarkdown, ...) was installed from cran.r-project.org at test time on every run: by globalSetup when it could, and by per-test ensurePackages self-healing when it could not. During a CRAN outage those installs hang mid-suite (s4_unloaded_package, shinytest2 in the pr-18449 all-platforms run) instead of failing fast. Pass install-required-packages to the deps action on every desktop engine, matching Linux (PR #18390), so the set is installed from PPM into the cached R library before tests and a warm cache installs nothing at all. The macOS workflows and the scheduled Windows autocomplete workflow also gain the PW_RSTUDIO_R_LIBS_USER wiring that points globalSetup at that same library (the main Windows workflow already had it). The Linux Server workflow deliberately keeps its own system-library seed: its sessions run as a per-run user, and tests that exercise uninstall flows (fortunes, DBI) cannot remove packages from a root-owned library.
Problem
The consolidated Linux e2e workflow (#18360) sets, in Run Playwright tests:
with the stated intent that the empty branch means "the harness default". But an Actions
env:value of''is exported as a defined empty string, andrLibsUserTemplate()read it with??:''is not nullish, so it won, and the R_LIBS_USER template became"".R treats an empty
R_LIBS_USERas unset and computes its HOME-relative default. globalSetup runs with the real HOME, so it installed REQUIRED_PACKAGES into/home/runner/R/x86_64-pc-linux-gnu-library/4.5; the session under test runs with HOME redirected into the per-run sandbox (desktop.fixture.ts), so it resolved a different, empty library. That is precisely the hazardr-libs-setup.ts's header comment warns about. The default template is immune becauseos.homedir()is resolved before the redirect, producing an absolute path.One line in the job log shows it, comparing the same branch before and after #18360 landed:
[r-libs] user library:/home/runner/.cache/rstudio-playwright/r-libs/x86_64-pc-linux-gnu/4.5/home/runner/R/x86_64-pc-linux-gnu-library/4.5Everything else in those two runs is identical, including the GWT cache hash.
Impact
citations.test.ts:147"inserts an R Package citation into the document" fails both attempts, deterministically, on linux-desktop shard 1 of every branch that has main merged in (runs 30296790097, 30429212918). The panel callsgetRPackageState()and Fuse-searches the session's installed packages; with the empty library there is no knitr, and the trace contains "No matching packages".Affected: the five engines with
preinstall_r_packages: ""--ubuntu-22-x86_64,ubuntu-24-x86_64,ubuntu-24-arm64,ubuntu-26-x86_64,debian-13-arm64. Fedora/Rocky pass a real path; macOS, Windows, and Linux Server never set the variable.Beyond the one red test, the harness's REQUIRED_PACKAGES pre-population was landing in a library the session never saw, so those engines were quietly running against a much thinner library.
Fix
??->||, which makes the workflow's documented intent true and also coversserver.fixture.ts, and the prep log now names where the resolved library came from:so a future override mismatch is visible in the job output instead of surfacing as a missing package.
Verification
npm run typecheckclean ine2e/rstudio.unsetandexplicit pathare unchanged;''returns""on main and the default template here.linux-desktop / E2E (ubuntu-24-x86_64)went green, shard 1 passedcitations.test.ts:147, and the log read[r-libs] user library: /home/runner/.cache/rstudio-playwright/... [harness default].Review follow-ups (089f2fd)
From the review, the items worth taking, all in the same file:
required-packages.txtwas split on'\n'only; on a Windows checkout the trailing\rdefeats/#.*$/(\ris a regex line terminator, so.stops at it and$anchors past it) and every comment line was passed toinstall.packages()as a package name -- which is exactly the permanent[r-libs] WARNING: failed to install: # R packages ...noise every Windows shard has been printing. Nowsplit(/\r?\n/). Verified against a CRLF rendition of the real manifest: old parse leaks 6 comment lines, new parse is byte-identical to the LF parse. (The action-side parser is R, not bash, and R's.crosses\r, so it needs no change.)tools:::->base::::.expand_R_libs_env_varlives inbase, sotools:::errored on every call and the reducedgsubfallback ran unconditionally. Harmless for the%p/%vtemplates in use (verified both paths expand identically), but%U/%S/%%would have been wrong. The fallback now writes a marker so a silent downgrade shows up in the prep log as aWARNING.prepareRLibs()does, so skip-prep runs and expansion failures are no longer diagnostic-free.Deliberately not taken:
console.warnfor the "set but empty" case (empty is the intended per-engine signal in the Linux workflow -- warning on it would fire on every run of five engines, permanently).Preinstall on every engine (aa7dbc6)
The review also observed that with the resolution fixed, the five
preinstall_r_packages: ""engines install the 23-package set into the harness-default library -- which no workflow cache covers -- on every run. This flipspreinstall_r_packages: "true"for all five, routing the install throughos-e2e-depsinto the cachedR-libstree (keyed on the manifest via-req<hash>) and pointingPW_RSTUDIO_R_LIBS_USERat it, so a warm run installs nothing.Two of them (
ubuntu-24-x86_64,ubuntu-26-x86_64) also get explicit cache scopes (noble-amd64/resolute-amd64): both used the legacy sharedLinuxkey, which was tolerable for pak's DESCRIPTION deps but is an ABI hazard once the cache carries the full compiled package set -- whichever engine saved first on main would hand its binaries to the other, and the presence check would count them as installed. Their caches start cold and warm on the next main-scoped run.The review's own suggested shape (unconditional
PW_RSTUDIO_R_LIBS_USER) would not have worked: the R-libs cache is saved inside the action -- before globalSetup runs, and only from main -- so anything globalSetup installs into that tree still never persists; and dropping the conditional would decouple the cache key from the manifest, since-req<hash>only applies wheninstall-required-packagesis set.With this commit the ubuntu-24 job's expected log line changes from the
.cache/rstudio-playwrightpath (verified at the first push, above) to[r-libs] user library: /home/runner/work/rstudio/rstudio/R-libs [PW_RSTUDIO_R_LIBS_USER=...], withos-e2e-depsdoing the install instead.No NEWS.md entry: CI-only, and the regression never reached a release.