fix(getCRANrepos): preserve other repos (e.g. r-universe) when resolving @CRAN@#175
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause (the "other place" resetting repos)
A workshop participant on RStudio running the same
global.Ras the maintainer kept failing underRequire.noRemotes— LandR/pemisc/scfmutils/LandR.CS "could not be found",simInitdied with "no package named 'LandR'" — and heroptions("repos")showed onlycran.rstudio.comdespite her script setting r-universe.getCRANrepos()is the culprit (distinct from the SpaDES.project #111 unnamed-repos fix):RStudio's default
options(repos)isc(CRAN = "@CRAN@")and RStudio setsCRAN_REPO(e.g.https://cran.rstudio.com/). So for any RStudio user who added an r-universe viaoptions(repos = unique(c(<r-universe>, getOption("repos")))), the momentgetCRANrepos()ran during install it wiped r-universe, leaving CRAN-only — exactly her observedcran.rstudio.com.noRemotesthen couldn't resolve the PE packages (they live on that r-universe). Never reproduced on the maintainer's machine becauseCRAN_REPOwasn't set there.Fix
Resolve the
"@CRAN@"placeholder(s) in place and preserve every other repo — mirroring thereposNow[!hasAts]handling a few lines below (which already does the right thing for the non-CRAN_REPObranch).Verified across cases (r-universe survives;
@CRAN@resolved; no-@CRAN@untouched). Regression test added. Bump2.0.0.9031→2.0.0.9033(.9032is the open bioc PR #174).🤖 Generated with Claude Code