don't treat biocViews as proof of bioconductor origin#2306
Merged
Conversation
renv used the presence of a biocViews field in a package's DESCRIPTION as proof that the package came from Bioconductor. Some CRAN packages declare biocViews, and Posit Package Manager can serve Bioconductor packages from a CRAN-like "R repository", so renv misclassified such packages as Bioconductor. Introduce renv_description_bioconductor(), which decides a package's origin from where it was obtained (the Repository field, and Bioconductor git provenance) rather than from biocViews alone, and rewire the snapshot, retrieve, graph, install, and lockfile call sites to use it. Also add a bioconductor.enabled project setting (default TRUE) so a project can opt out of Bioconductor entirely. #2128
On R-devel, Bioconductor often has no usable release yet (BiocManager maps the R version only to a 'future' Bioconductor release with no installable packages), so the live bioc install tests fail with "failed to install". Add renv_bioconductor_supported(), which consults BiocManager's R-to- Bioconductor version map and reports whether the running R maps to a Bioconductor release with a usable status, and a skip_if_no_bioconductor() test helper built on it. Guard the tests that perform real Bioconductor installs or resolution.
R CMD build in R-devel (r90095, PR#17549) fails to build a package whose source tree contains only top-level files, because the build directory is created solely from the package's subdirectories; the test-r.R fixture was a DESCRIPTION-only package and hit this. Add renv_package_skeleton() to utils.R, which writes a minimal but complete package (DESCRIPTION, NAMESPACE, and an R/ directory), and use it in test-r.R so the package both builds and installs.
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.
Problem
renv used the presence of a
biocViewsfield in a package'sDESCRIPTIONas "proof" that the package came from Bioconductor (#2128, problem 1). But some CRAN packages legitimately declarebiocViews, and Posit Package Manager can serve Bioconductor packages from a CRAN-like "R repository". In those cases renv misclassified the package: it recordedSource: Bioconductor, activated the Bioconductor repositories, and injected aBioconductor/BiocVersionblock into the lockfile -- pulling the package frombioconductor.orginstead of the repository it actually came from.Approach
The key insight is that what matters for restore is where a package was obtained (the
Repositoryfield) rather than where it originally came from (its git provenance). A genuine Bioconductor package'sDESCRIPTIONcarriesRepository: Bioconductor <ver>(andgit_url: https://git.bioconductor.org/...); a CRAN/PPM package carriesRepository: CRAN(or a repo name).New helper
renv_description_bioconductor(dcf)(R/bioconductor.R) decides origin by precedence:biocViews-> not Bioconductor;Repositorycontains "Bioconductor" (matched anywhere, case-insensitive, so custom-named PPM Bioconductor repositories are recognized) -> Bioconductor;Repositoryis CRAN / a known mirror / one of the active repos -> not Bioconductor (covers CRAN packages and PPM CRAN-like "R repositories", even when they retain Bioconductor git provenance);git_urlprovenance, then to the historical behaviour of trustingbiocViews.The snapshot classification,
_source_custom, field-strip blocks,retrieve.Rrepo activation,graph.Rresolution,install.R, andlockfile.Rcall sites are rewired to use this (and the new setting below) instead of a barenzchar(biocViews)check. Because the lockfileBioconductorblock is driven bySource == "Bioconductor", correcting classification also resolves the unwantedBiocVersion/repo injection (problem 2) for the misclassified case.New
bioconductor.enabledproject setting (logical, defaultTRUE, persisted inrenv/settings.json). WhenFALSE, renv never infers a Bioconductor source, activates the Bioconductor repositories, or writes a Bioconductor entry into the lockfile -- a first-class opt-out for repository-only projects, replacing theoptions(renv.bioconductor.repos = ...)workaround.Notes on PPM / mirrors
renv does not hard-code Bioconductor URLs: it asks
BiocManager(which honorsBioC_mirror) for the repositories, or uses therenv.bioconductor.reposoverride verbatim. So a PPM Bioconductor mirror is used automatically when configured, and needs no special handling here. The vignette is updated to explain theBioC_mirrorvsrenv.bioconductor.reposdistinction and the reproducibility options. Capturing the mirror in the lockfile was considered and deliberately left out of scope.Testing
Added snapshot tests covering: CRAN +
biocViews->Repository; a CRAN-like (PPM) repo +biocViews+ bioc git provenance ->Repository; genuineRepository: Bioconductorand custom-named PPM bioc repos ->Bioconductor; andbioconductor.enabled = FALSEdisabling inference and the lockfile entry.All passing locally: snapshot, bioconductor, settings, lockfile, install, graph, retrieve, restore (0 failures).
Closes #2128.