Skip to content

fix(getCRANrepos): preserve other repos (e.g. r-universe) when resolving @CRAN@#175

Merged
eliotmcintire merged 1 commit into
developmentfrom
fix/getCRANrepos-preserve-runiverse
Jun 10, 2026
Merged

fix(getCRANrepos): preserve other repos (e.g. r-universe) when resolving @CRAN@#175
eliotmcintire merged 1 commit into
developmentfrom
fix/getCRANrepos-preserve-runiverse

Conversation

@eliotmcintire

Copy link
Copy Markdown
Contributor

Root cause (the "other place" resetting repos)

A workshop participant on RStudio running the same global.R as the maintainer kept failing under Require.noRemotes — LandR/pemisc/scfmutils/LandR.CS "could not be found", simInit died with "no package named 'LandR'" — and her options("repos") showed only cran.rstudio.com despite her script setting r-universe.

getCRANrepos() is the culprit (distinct from the SpaDES.project #111 unnamed-repos fix):

if (isTRUE("@CRAN@" %in% repos)) {
  cranRepo <- Sys.getenv("CRAN_REPO")
  repos <- if (nzchar(cranRepo)) {
    options("repos" = c("CRAN" = cranRepo))   # <-- replaces ENTIRE repos with CRAN-only

RStudio's default options(repos) is c(CRAN = "@CRAN@") and RStudio sets CRAN_REPO (e.g. https://cran.rstudio.com/). So for any RStudio user who added an r-universe via options(repos = unique(c(<r-universe>, getOption("repos")))), the moment getCRANrepos() ran during install it wiped r-universe, leaving CRAN-only — exactly her observed cran.rstudio.com. noRemotes then couldn't resolve the PE packages (they live on that r-universe). Never reproduced on the maintainer's machine because CRAN_REPO wasn't set there.

Fix

Resolve the "@CRAN@" placeholder(s) in place and preserve every other repo — mirroring the reposNow[!hasAts] handling a few lines below (which already does the right thing for the non-CRAN_REPO branch).

Verified across cases (r-universe survives; @CRAN@ resolved; no-@CRAN@ untouched). Regression test added. Bump 2.0.0.90312.0.0.9033 (.9032 is the open bioc PR #174).

🤖 Generated with Claude Code

…ing @cran@

getCRANrepos(), when repos contained "@cran@" AND the CRAN_REPO env var was set,
ran `options("repos" = c("CRAN" = cranRepo))` -- REPLACING the entire repos
vector with CRAN-only and silently dropping every other repo.

That is exactly RStudio's default state: options(repos) is c(CRAN = "@cran@")
and RStudio sets CRAN_REPO (e.g. https://cran.rstudio.com/). So an RStudio user
who set `options(repos = unique(c(<r-universe>, getOption("repos"))))` (as the
SpaDES workshop global.R does) had their r-universe wiped the moment
getCRANrepos ran during the install. Require.noRemotes then could not find the
PredictiveEcology packages (LandR, pemisc, scfmutils, LandR.CS) -- they resolve
from that r-universe -- and the run died at simInit with "no package named
'LandR'". It only reproduced for RStudio users with CRAN_REPO set, which is why
it was invisible on the maintainer's machine. Distinct from the SpaDES.project
#111 unnamed-repos fix; this is the *other* place that reset repos.

Resolve the "@cran@" placeholder(s) in place and keep all other repos, mirroring
the existing `reposNow[!hasAts]` handling a few lines below.

Test: test-17usePak.R "getCRANrepos preserves non-CRAN repos when resolving
@cran@". Bump .9031 -> .9033 (.9032 is the open bioc PR #174).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eliotmcintire eliotmcintire merged commit 51056f5 into development Jun 10, 2026
13 of 14 checks passed
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