├── .Rbuildignore ├── .gitignore ├── DESCRIPTION ├── NAMESPACE ├── NEWS ├── R ├── BiocManager-package.R ├── available.R ├── inet.R ├── install.R ├── repositories.R ├── utilities.R ├── valid.R ├── version.R └── zzz.R ├── README.Rmd ├── README.md ├── cran-comments.md ├── man ├── BiocManager-package.Rd ├── available.Rd ├── figures │ └── BiocManager.png ├── install.Rd ├── repositories.Rd ├── valid.Rd └── version.Rd ├── tests ├── testthat.R └── testthat │ ├── test_inet.R │ ├── test_install.R │ ├── test_repositories.R │ ├── test_valid.R │ └── test_version.R └── vignettes ├── BiocManager.Rmd └── img ├── archives.png └── badges.png /.Rbuildignore: -------------------------------------------------------------------------------- 1 | #---------------------------- 2 | # Git 3 | #---------------------------- 4 | ^\.git$ 5 | ^\.gitignore$ 6 | ^\.gitattributes$ 7 | ^\.github$ 8 | 9 | #---------------------------- 10 | # RStudio and R 11 | #---------------------------- 12 | ^\.Rhistory$ 13 | ^.*\.Rproj$ 14 | ^\.Rproj\.user$ 15 | 16 | #---------------------------- 17 | # Misc. 18 | #---------------------------- 19 | ^TODO\.md$ 20 | ^cran-comments\.md$ 21 | ^README\.Rmd$ 22 | 23 | #---------------------------- 24 | # Continuous Integration 25 | #---------------------------- 26 | ^appveyor\.yml$ 27 | ^\.travis\.yml$ 28 | ^_pkgdown\.yml$ 29 | ^docs$ 30 | ^pkgdown$ 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | *.Rproj 6 | docs 7 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: BiocManager 2 | Title: Access the Bioconductor Project Package Repository 3 | Description: A convenient tool to install and update Bioconductor packages. 4 | Version: 1.30.26 5 | Authors@R: c( 6 | person("Martin", "Morgan", email = "martin.morgan@roswellpark.org", 7 | role = "aut", comment = c(ORCID = "0000-0002-5874-8148")), 8 | person("Marcel", "Ramos", email = "marcel.ramos@sph.cuny.edu", 9 | role = c("aut", "cre"), comment = c(ORCID = "0000-0002-3242-0582"))) 10 | Imports: 11 | utils 12 | Suggests: 13 | BiocVersion, 14 | BiocStyle, 15 | remotes, 16 | rmarkdown, 17 | testthat, 18 | withr, 19 | curl, 20 | knitr 21 | URL: https://bioconductor.github.io/BiocManager/ 22 | BugReports: https://github.com/Bioconductor/BiocManager/issues 23 | VignetteBuilder: knitr 24 | License: Artistic-2.0 25 | Encoding: UTF-8 26 | RoxygenNote: 7.3.2 27 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(format,version_sentinel) 4 | S3method(print,biocValid) 5 | S3method(print,version_sentinel) 6 | export(available) 7 | export(containerRepository) 8 | export(install) 9 | export(repositories) 10 | export(valid) 11 | export(version) 12 | importFrom(stats,setNames) 13 | importFrom(utils,available.packages) 14 | importFrom(utils,contrib.url) 15 | importFrom(utils,download.file) 16 | importFrom(utils,head) 17 | importFrom(utils,install.packages) 18 | importFrom(utils,installed.packages) 19 | importFrom(utils,old.packages) 20 | importFrom(utils,packageVersion) 21 | importFrom(utils,sessionInfo) 22 | importFrom(utils,tail) 23 | importFrom(utils,update.packages) 24 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | CHANGES IN VERSION 1.30.26 2 | ------------------------- 3 | 4 | MINOR CHANGES 5 | 6 | o Remove mention of biocLite script and remove `.LEGACY_INSTALL_CMD` 7 | (@sneumann, #195) 8 | o Explain management of multiple Bioconductor versions when using the same 9 | R version in the vignette 10 | o Use `BIOCONDUCTOR_NAME` environment variable for binary URL resolution 11 | (@almahmoud, #199) 12 | o Use `download.file` to obtain the `config.yaml` file before running 13 | `readLines` (@glin, #198) 14 | 15 | CHANGES IN VERSION 1.30.25 16 | ------------------------- 17 | 18 | MINOR CHANGES 19 | 20 | o Maintainer email change. 21 | 22 | CHANGES IN VERSION 1.30.24 23 | ------------------------- 24 | 25 | NEW FEATURES 26 | 27 | o Force BiocManager to use unsupported version of R with `R_BIOC_VERSION` 28 | environment variable (@mtmorgan, #193) 29 | 30 | CHANGES IN VERSION 1.30.23 31 | ------------------------- 32 | 33 | NEW FEATURES 34 | 35 | o Ensure compatibility with `package_version` changes in R 4.4.0 36 | (@kurthornik) 37 | 38 | MINOR CHANGES 39 | 40 | o Added "Updating old packages" and "Archived CRAN packages" sections in 41 | the vignette 42 | o Use `BiocStyle` formatting in the vignette 43 | o Update Posit links in the vignette 44 | 45 | CHANGES IN VERSION 1.30.22 46 | ------------------------- 47 | 48 | NEW FEATURES 49 | 50 | o Enable site_repository environment variable or option for install, valid 51 | 52 | MINOR CHANGES 53 | 54 | o Ensure character input to package_version function (@kurthornik) 55 | 56 | CHANGES IN VERSION 1.30.21 57 | ------------------------- 58 | 59 | NEW FEATURES 60 | 61 | o Enable the use of the Bioc-devel branch on R-devel during the 'summer' 62 | release cycle (@mtmorgan, #166) 63 | o Allow `BIOCMANAGER_SITE_REPOSITORY` environment variable and 64 | `BiocManager.site_repository` option as a more permanent option for 65 | `site_repository` users (@LiNk-NY). 66 | o Support for "time machine" CRAN installations has moved to BiocArchive 67 | and has been removed from the package (#151, @LiNk-NY) 68 | 69 | MINOR CHANGES 70 | 71 | o Correct links on help pages. See 72 | ; thanks 73 | @aitap 74 | o Additional documentation provided for offline use of BiocManager in 75 | `?install` and in the main vignette (#165, @mtmorgan). 76 | 77 | CHANGES IN VERSION 1.30.20 78 | ------------------------- 79 | 80 | NEW FEATURES 81 | 82 | o Add `BIOCMANAGER_CHECK_REPOSITORIES` environment variable for 83 | non-interactive sessions as an alternative to the 84 | `BiocManager.check_repositories` option (#144, @HenrikBengtsson) 85 | 86 | MINOR CHANGES 87 | 88 | o Re-use and translate `update` and `ask` arguments when installing via 89 | `install_github` (#126, @Jiefei-Wang) 90 | o Allow `type` argument during package installation to opt out of binary 91 | installations (#103, @lshep) 92 | o Check `BiocVersion` installation with `system.file` rather than with 93 | `packageVersion` (K. Hornik) 94 | 95 | CHANGES IN VERSION 1.30.19 96 | ------------------------- 97 | 98 | MINOR CHANGES 99 | 100 | o Updated warning message for clarity when packages are installed of the 101 | same version or greater. 102 | o The `ask` argument is passed through to the `remotes::install_github` 103 | o Update unit tests which did not include the full scenario of options 104 | o Catch zero length outputs when timeouts occur (#140, @hpages) 105 | 106 | CHANGES IN VERSION 1.30.18 107 | ------------------------- 108 | 109 | MINOR CHANGES 110 | 111 | o Increase robustness of code when loading and working with the 112 | version map 113 | o Add internal checks to version tags in map and update unit tests 114 | o Include a 'troubleshooting' section in the vignette 115 | 116 | CHANGES IN VERSION 1.30.17 117 | ------------------------- 118 | 119 | NEW FEATURES 120 | 121 | o `containerRepository` reports the location of binary packages for 122 | containerized images of Bioconductor, if available. 123 | 124 | BUG FIXES 125 | 126 | o `install` appropriately returns a warning from `install.packages` instead 127 | of a character vector (#112, @mtmorgan). 128 | 129 | CHANGES IN VERSION 1.30.16 130 | ------------------------- 131 | 132 | BUG FIXES 133 | 134 | o Ensure that the `force` argument is passed along after installation of 135 | `BiocVersion` (#105, @lshep, @jwokaty) 136 | o Fix typo in `.VERSION_MAP_SENTINEL` (`RSPM` column name). 137 | 138 | CHANGES IN VERSION 1.30.15 139 | ------------------------- 140 | 141 | BUG FIXES 142 | 143 | o `.skip_if_misconfigured` function should work with 144 | `_R_CHECK_DEPENDS_ONLY=true` 145 | o Switch to `interactive()` only examples for `available()` 146 | 147 | CHANGES IN VERSION 1.30.14 148 | ------------------------- 149 | 150 | BUG FIXES 151 | 152 | o `install` now passes the `force` argument to `install_github` 153 | (#101, @lgeistlinger) 154 | o Treat warnings as warnings internally in `install.packages()` 155 | (#100, @biobenkj) 156 | o Check version validity `.onAttach` rather than `.onLoad` 157 | 158 | CHANGES IN VERSION 1.30.13 159 | ------------------------- 160 | 161 | NEW FEATURES 162 | 163 | o Downloading the same version of a remote package already installed will 164 | be avoided unless the user supplies `force=TRUE` to `install`. 165 | 166 | USER VISIBLE CHANGES 167 | 168 | o Devel users on a newer version of R will not get an error when the minor 169 | version of R is +1 of the recommended 170 | 171 | BUG FIXES 172 | 173 | o Added a warning and informative message when a package is 'not available' 174 | (#85, @LTLA). 175 | o `BIOCONDUCTOR_CONFIG_FILE` now included in the documentation for 176 | `install` (#93, @glin). 177 | 178 | 179 | 180 | CHANGES IN VERSION 1.30.12 181 | ------------------------- 182 | 183 | NEW FEATURES 184 | 185 | o 'BIOCONDUCTOR_CONFIG_FILE' option allows users to provide an offline 186 | and local configuration file (config.yaml) for version validation. 187 | 188 | o Bioconductor 'BioCbooks' repository now available in Bioconductor 189 | versions >= "3.12" 190 | 191 | USER VISIBLE CHANGES 192 | 193 | o Enable use of historical snapshots ('MRAN' or 'RSPM' via 194 | `options(BiocManager.snapshots=)`) to install CRAN packages for 195 | out-of-date Bioconductor versions. 196 | 197 | o Respect `options(repos = c(CRAN = "..."))`. See 198 | https://github.com/Bioconductor/BiocManager/issues/69 199 | 200 | BUG FIXES 201 | 202 | o Increase timeout from 1 to 5 minutes (300 seconds) to make 203 | download of large packages more robust. 204 | 205 | CHANGES IN VERSION 1.30.10 206 | ------------------------- 207 | 208 | MINOR CHANGES 209 | 210 | o Restore startup message with recommended version 211 | 212 | o Update mis-configuration skip in tests 213 | 214 | CHANGES IN VERSION 1.30.9 215 | ------------------------- 216 | 217 | MINOR CHANGES 218 | 219 | o Use `packageStartupMessage()` in .onLoad 220 | 221 | o Tests are robust to missing Suggests: BiocVersion 222 | 223 | CHANGES IN VERSION 1.30.8 224 | ------------------------- 225 | 226 | MINOR CHANGES 227 | 228 | o Tests are skipped if is there is a misconfiguration or the CRAN 229 | builder has no internet access. 230 | 231 | CHANGES IN VERSION 1.30.7 232 | ------------------------- 233 | 234 | NEW FEATURES 235 | 236 | o Support R-4.0 237 | 238 | MINOR CHANGES 239 | 240 | o Conform to CRAN policy to fail with messages rather than 241 | warnings or errors when internet access fails; internet access 242 | failures continue to generate warnings or errors during regular 243 | use. 244 | 245 | CHANGES IN VERSION 1.30.6 246 | ------------------------- 247 | 248 | MINOR CHANGES 249 | 250 | o Improve unit tests under Bioconductor versions 3.8, 3.9, 3.10. 251 | 252 | o Improve error message when non-interactive version update fails. 253 | 254 | BUG FIXES 255 | 256 | o BiocManager loads when off-line. 257 | 258 | CHANGES IN VERSION 1.30.5 259 | ------------------------- 260 | 261 | NEW FEATURES 262 | 263 | o Allow users to specify `checkBuilt` when invoking `valid()` or 264 | `install()`. Set default `FALSE`. 265 | 266 | MINOR CHANGES 267 | 268 | o Allow use of BiocInstaller for R < 3.5, pointing to biocLite() 269 | when appropriate. 270 | 271 | o Improve performance of version checking (issue #42 @HenrikBengtsson). 272 | 273 | o Document off-line installation best practices. 274 | 275 | o Warn about out-of-date packages on load (in addition to on 276 | attach) (issue #29) 277 | 278 | CHANGES IN VERSION 1.30.4 279 | ------------------------- 280 | 281 | NEW FEATURES 282 | 283 | o Provide an 'http' fallback when 'https' fails for accessing the version 284 | map hosted on Bioconductor.org 285 | 286 | MINOR CHANGES 287 | 288 | o Conform tests to devel and release R versions 289 | o Add tests for the 'http' fallback scenarios 290 | 291 | BUG FIXES 292 | 293 | o Fixed issue with multiple error version messages for Bioc version `3.9` 294 | 'devel' and 'future' 295 | o Return a warning message instead of an error when unable to validate 296 | a given version 297 | 298 | CHANGES IN VERSION 1.30.3 299 | ------------------------- 300 | 301 | NEW FEATURES 302 | 303 | o 'BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS' option allows users to skip 304 | online version map validation. Local installation of 'BiocVersion' will be 305 | used when this option is enabled. 306 | 307 | MINOR CHANGES 308 | 309 | o Removed extra prompts when switching versions and updating packages 310 | 311 | o Clarified 'See Also' documentation (@lwaldron #16) 312 | 313 | o Added several unit tests to increase robustness (@mtmorgan) 314 | 315 | BUG FIXES 316 | 317 | o Obtain CRAN 'repos' option independent of name (@kasperdanielhansen #17) 318 | 319 | o Fixed a bug when switching to 'devel' version of Bioconductor 320 | (@kasperdanielhansen #25) 321 | 322 | o When installation is valid, return zero invalid packages rather than 323 | accessing non-existent list structure 324 | 325 | CHANGES IN VERSION 1.30.2 326 | ------------------------- 327 | 328 | USER VISIBLE CHANGES 329 | 330 | o install() only allows Bioconductor version upgrades and downgrades with 331 | an empty 'pkgs' argument. Otherwise, it gives the user an informative error. 332 | 333 | o 'ask' argument is respected when in non-interactive mode (@lshep #9) 334 | 335 | o valid() returns TRUE for valid Bioconductor installations otherwise, 336 | it prints a report of out-of-date and/or too new packages 337 | 338 | MINOR CHANGES 339 | 340 | o updated unit tests for install() 341 | 342 | o when changing versions via 'install(version = "x.x")', Bioconductor 343 | packages to be up or down-graded are now enumerated 344 | 345 | BUG FIXES 346 | 347 | o Remove tests that were dependent on system configuration rather 348 | than the package itself 349 | 350 | CHANGES IN VERSION 1.30.1 351 | ------------------------- 352 | 353 | USER VISIBLE CHANGES 354 | 355 | o install() '...' arguments must be named. 356 | 357 | CHANGES IN VERSION 1.30.0 358 | ------------------------- 359 | 360 | NEW FEATURES 361 | 362 | o package renamed to BiocManager 363 | 364 | o install() supports github repositories using the remotes 365 | package, rather than devtools. This change should be transparent 366 | to end users. (@PeteHaitch, #4) 367 | 368 | o functions renamed to the following: biocLite > install; 369 | biocInstallRepos > repositories; biocValid > valid; 370 | biocVersion > version 371 | 372 | o functions removed: biocases_group, biocUpdatePackages, isDevel, 373 | useDevel, *_group 374 | 375 | o available() enables package discovery via grep() 376 | 377 | o Removed support for MRAN (Microsoft R) archives. 378 | 379 | CHANGES IN VERSION 1.28.0 380 | ------------------------- 381 | 382 | NEW FEATURES 383 | 384 | o biocLite() supports full URLs, e.g., to archived Bioconductor 385 | packages. 386 | 387 | o Support MRAN (Microsoft R) archives. 388 | 389 | CHANGES IN VERSION 1.24.0 390 | ------------------------- 391 | 392 | NEW FEATURES 393 | 394 | o biocLite() uses lib.loc= to find devtools, reports more 395 | informatively why devtools fails to load 396 | 397 | o biocLite() only offers to update non-masked packages 398 | 399 | o biocLite() reports when packages in unwriteable directories are 400 | out-of-date, but does not try (and fail) to update them. 401 | 402 | o isDevel() returns TRUE if the version of BiocInstaller 403 | corresponds to the development version of Bioconductor. 404 | 405 | CHANGES IN VERSION 1.20.0 406 | ------------------------- 407 | 408 | BUG FIXES 409 | 410 | o biocLite() uses lib.loc when calling update.packages 411 | 412 | CHANGES IN VERSION 1.18.0 413 | ------------------------- 414 | 415 | NEW FEATURES 416 | 417 | o biocLite() supports github repositories (implicitly, 'packages' 418 | following the 'maintainer/package' convention) 419 | 420 | CHANGES IN VERSION 1.14.0 421 | ------------------------- 422 | 423 | NEW FEATURES 424 | 425 | o biocUpdatePackages updates installed packages and their 426 | dependencies. 427 | 428 | CHANGES IN VERSION 1.10.0 429 | ------------------------- 430 | 431 | NEW FEATURES 432 | 433 | o biocValid() checks that installed packages are consistent with 434 | those available via biocLite(). 435 | 436 | o biocVersion() returns the version of Bioconductor expected with 437 | this version of the BiocInstaller package. 438 | 439 | USER-VISIBLE CHANGES 440 | 441 | o biocLite() invoked with no arguments updates currently installed 442 | packages to their most-recent version. 443 | 444 | -------------------------------------------------------------------------------- /R/BiocManager-package.R: -------------------------------------------------------------------------------- 1 | #' @importFrom utils packageVersion contrib.url head 2 | #' installed.packages sessionInfo tail 3 | NULL 4 | 5 | #' Install or update Bioconductor, CRAN, or GitHub packages 6 | #' 7 | #' @aliases R_BIOC_VERSION 8 | #' 9 | #' @description 10 | #' 11 | #' This package provides tools for managing _Bioconductor_ and other 12 | #' packages in a manner consistent with _Bioconductor_'s package 13 | #' versioning and release system. 14 | #' 15 | #' @details 16 | #' 17 | #' Main functions are as follows; additional help is available for 18 | #' each function, e.g., `?BiocManager::version`. 19 | #' 20 | #' - `BiocManager::install()`: Install or update packages from 21 | #' _Bioconductor_, CRAN, and GitHub. 22 | #' 23 | #' - `BiocManager::version()`: Report the version of _Bioconductor_ in 24 | #' use. 25 | #' 26 | #' - `BiocManager::available()`: Return a `character()` vector of 27 | #' package names available (at `BiocManager::repositories()`) for 28 | #' installation. 29 | #' 30 | #' - `BiocManager::valid()`: Determine whether installed packages are 31 | #' from the same version of _Bioconductor_. 32 | #' 33 | #' - `BiocManager::repositories()`: _Bioconductor_ and other 34 | #' repository URLs to discover packages for installation. 35 | #' 36 | #' The version of _Bioconductor_ in use is determined by the installed 37 | #' version of a second package, BiocVersion. BiocVersion is installed 38 | #' automatically during first use of `BiocManager::install()`. If 39 | #' BiocVersion has not yet been installed, the version is determined 40 | #' by code in base R. 41 | #' 42 | #' Options influencing package behavior (see `?options`, `?getOption`) 43 | #' include: 44 | #' 45 | #' - `"repos"`, `"BiocManager.check_repositories"`: URLs of additional 46 | #' repositories for use by `BiocManger::install()`. See `?repositories`. 47 | #' 48 | #' - `"pkgType"`: The default type of packages to be downloaded and 49 | #' installed; see `?install.packages`. 50 | #' 51 | #' - `"timeout"`: The maximum time allowed for download of a single 52 | #' package, in seconds. _BiocManager_ increases this to 300 seconds 53 | #' to accommodate download of large BSgenome and other packages. 54 | #' 55 | #' System environment variables influencing package behavior include: 56 | #' 57 | #' - \env{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} advanced 58 | #' configuration to avoid _Bioconductor_ version checks. See 59 | #' `?install`. 60 | #' 61 | #' - \env{BIOCONDUCTOR_CONFIG_FILE} for offline use of BiocManager 62 | #' versioning functionality. See `?install`. 63 | #' 64 | #' - \env{BIOCONDUCTOR_USE_CONTAINER_REPOSITORY} opt out of binary package 65 | #' installations. See `?containerRepository`. 66 | #' 67 | #' - \env{BIOCMANAGER_CHECK_REPOSITORIES} silence messages regarding 68 | #' non-standard CRAN or Bioconductor repositories. See `?repositories`. 69 | #' 70 | #' - \env{BIOCMANAGER_SITE_REPOSITORY} configure a more permanent 71 | #' `site_repository` input to `repositories()`. See `?repositories`. 72 | #' 73 | #' - \env{R_BIOC_VERSION} use a specific, possibly unsupported, 74 | #' version of Bioconductor. `install()`, `version()`, `available()`, 75 | #' `valid()`, and `repositories()` all use the version *without* 76 | #' checking that it is consistent with the version of *R* in use. 77 | #' 78 | #' @md 79 | #' @aliases BiocManager 80 | #' 81 | #' @examples 82 | #' R.version.string 83 | #' packageVersion("BiocManager") 84 | #' if (requireNamespace("BiocVersion", quietly = TRUE)) 85 | #' packageVersion("BiocVersion") 86 | #' BiocManager::version() 87 | "_PACKAGE" 88 | -------------------------------------------------------------------------------- /R/available.R: -------------------------------------------------------------------------------- 1 | #' Discover packages available for installation. 2 | #' 3 | #' The function lists all packages available from \code{repositories()} when 4 | #' no pattern is provided. This usually includes CRAN and Bioconductor 5 | #' packages. The function can also be used to check for package name 6 | #' availability. Common use cases include annotation package lookups by 7 | #' organism short name (e.g., "hsapiens"). 8 | #' 9 | #' @param pattern character(1) pattern to filter (via 10 | #' `grep(pattern=...)`) available packages; the filter is not case 11 | #' sensitive. 12 | #' 13 | #' @param include_installed logical(1) When `TRUE`, include installed 14 | #' packages in list of available packages; when `FALSE`, exclude 15 | #' installed packages. 16 | #' 17 | #' @return `character()` vector of package names available for 18 | #' installation. 19 | #' 20 | #' @examples 21 | #' if (interactive()) { 22 | #' avail <- BiocManager::available() 23 | #' length(avail) 24 | #' 25 | #' BiocManager::available("bs.*hsapiens") 26 | #' } 27 | #' @md 28 | #' @export 29 | available <- 30 | function(pattern = "", include_installed = TRUE) 31 | { 32 | stopifnot( 33 | is.character(pattern), length(pattern) == 1L, !is.na(pattern), 34 | is.logical(include_installed), length(include_installed) == 1L, 35 | !is.na(include_installed) 36 | ) 37 | 38 | answer <- character() 39 | repos <- .repositories_filter(repositories()) 40 | if (length(repos)) 41 | answer <- rownames(.inet_available.packages(repos = repos)) 42 | answer <- sort(grep(pattern, answer, value = TRUE, ignore.case = TRUE)) 43 | if (!include_installed) 44 | answer <- setdiff(answer, rownames(installed.packages())) 45 | answer 46 | } 47 | -------------------------------------------------------------------------------- /R/inet.R: -------------------------------------------------------------------------------- 1 | #' @importFrom utils available.packages install.packages old.packages 2 | #' update.packages 3 | NULL 4 | 5 | .inet_warning <- 6 | function(w) 7 | { 8 | if (.is_CRAN_check()) { 9 | .message(conditionMessage(w)) 10 | } else { 11 | warning(w) 12 | } 13 | invokeRestart("muffleWarning") 14 | } 15 | 16 | .inet_error <- 17 | function(e) 18 | { 19 | if (.is_CRAN_check()) { 20 | .message(conditionMessage(e)) 21 | } else { 22 | stop(e) 23 | } 24 | } 25 | 26 | .inet_readChar <- 27 | function(...) 28 | { 29 | withCallingHandlers({ 30 | tryCatch({ 31 | readChar(...) 32 | }, error = function(e) { 33 | .inet_error(e) 34 | character() 35 | }) 36 | }, warning = .inet_warning) 37 | } 38 | 39 | #' @importFrom utils download.file 40 | .inet_readLines <- 41 | function(...) 42 | { 43 | withCallingHandlers({ 44 | tryCatch({ 45 | tmp_config <- tempfile() 46 | download.file(..., destfile = tmp_config, quiet = TRUE) 47 | readLines(tmp_config) 48 | }, error = function(e) { 49 | .inet_error(e) 50 | e 51 | }) 52 | }, warning = .inet_warning) 53 | } 54 | 55 | .inet_available.packages <- 56 | function(...) 57 | { 58 | withCallingHandlers({ 59 | tryCatch({ 60 | available.packages(...) 61 | }, error = function(e) { 62 | .inet_error(e) 63 | colnames <- c( 64 | "Package", "Version", "Priority", "Depends", 65 | "Imports", "LinkingTo", "Suggests", "Enhances", 66 | "License", "License_is_FOSS", "License_restricts_use", 67 | "OS_type", "Archs", "MD5sum", "NeedsCompilation", 68 | "File", "Repository" 69 | ) 70 | matrix(character(0), ncol = 17, dimnames = list(NULL, colnames)) 71 | }) 72 | }, warning = .inet_warning) 73 | } 74 | 75 | .inet_install.packages <- 76 | function(...) 77 | { 78 | ## More generous timeout for large package download, see 79 | ## `?download.file` and, for instance, 80 | ## https://stat.ethz.ch/pipermail/bioc-devel/2020-November/017448.html 81 | if (identical(as.integer(getOption("timeout")), 60L)) { # change default only 82 | otimeout <- options(timeout = 300L) 83 | on.exit(options(otimeout)) 84 | } 85 | withCallingHandlers({ 86 | tryCatch({ 87 | install.packages(...) 88 | }, error = function(e) { 89 | .inet_error(e) 90 | invisible(NULL) 91 | }) 92 | }, warning = function(w) { 93 | msg <- conditionMessage(w) 94 | if (grepl("not available", msg)) { 95 | msg <- gsub( 96 | "this version of R", 97 | paste0("Bioconductor version ", "'", version(), "'"), 98 | msg 99 | ) 100 | w <- simpleWarning(msg, conditionCall(w)) 101 | } 102 | .inet_warning(w) 103 | }) 104 | } 105 | 106 | .inet_old.packages <- 107 | function(...) 108 | { 109 | withCallingHandlers({ 110 | tryCatch({ 111 | old.packages(...) 112 | }, error = function(e) { 113 | .inet_error(e) 114 | invisible(NULL) 115 | }) 116 | }, warning = .inet_warning) 117 | } 118 | 119 | .inet_update.packages <- 120 | function(...) 121 | { 122 | ## see .inet_old.packages for implementation note 123 | if (identical(as.integer(getOption("timeout")), 60L)) { 124 | otimeout <- options(timeout = 300L) 125 | on.exit(options(otimeout)) 126 | } 127 | withCallingHandlers({ 128 | tryCatch({ 129 | update.packages(...) 130 | }, error = function(e) { 131 | .inet_error(e) 132 | invisible(NULL) 133 | }) 134 | }, warning = .inet_warning) 135 | } 136 | -------------------------------------------------------------------------------- /R/install.R: -------------------------------------------------------------------------------- 1 | .package_filter_masked <- 2 | function(pkgs) 3 | { 4 | path0 <- normalizePath(pkgs[, "LibPath"], winslash="/") 5 | path1 <- normalizePath(.libPaths(), winslash="/") 6 | idx <- order(match(path0, path1)) 7 | dup <- duplicated(pkgs[idx,"Package"])[order(idx)] 8 | pkgs[!dup,, drop=FALSE] 9 | } 10 | 11 | .package_filter_unwriteable <- 12 | function(pkgs, instlib=NULL) 13 | { 14 | if (!nrow(pkgs)) 15 | return(pkgs) 16 | 17 | libs <- 18 | if (is.null(instlib)) { 19 | pkgs[,"LibPath"] 20 | } else instlib 21 | 22 | ulibs <- unique(libs) 23 | status <- dir.exists(ulibs) 24 | 25 | if (.Platform$OS.type == "windows") { 26 | status[status] <- vapply(ulibs[status], function(lib) { 27 | ## from tools::install.R: file.access() unreliable on 28 | ## Windows 29 | fn <- file.path(lib, paste0("_test_dir", Sys.getpid())) 30 | unlink(fn, recursive = TRUE) # precaution 31 | res <- try(dir.create(fn, showWarnings = FALSE)) 32 | if (inherits(res, "try-error") || !res) { 33 | FALSE 34 | } else { 35 | unlink(fn, recursive = TRUE) 36 | TRUE 37 | } 38 | }, logical(1)) 39 | } else 40 | status[status] <- file.access(ulibs[status], 2L) == 0 41 | 42 | status <- status[match(libs, ulibs)] 43 | if (!all(status)) { 44 | failed_pkgs <- pkgs[!status, "Package"] 45 | failed_lib <- pkgs[!status, "LibPath"] 46 | failed <- split(failed_pkgs, failed_lib) 47 | detail <- paste( 48 | mapply(function(lib, pkg) { 49 | paste0( 50 | " path: ", lib, "\n", 51 | " packages:\n", 52 | .msg(paste(pkg, collapse = ", "), indent = 4, exdent = 4) 53 | ) 54 | }, names(failed), unname(failed), USE.NAMES = FALSE), 55 | collapse = "\n" 56 | ) 57 | message( 58 | .msg("Installation paths not writeable, unable to update packages"), 59 | "\n", 60 | detail 61 | ) 62 | } 63 | 64 | pkgs[status,, drop=FALSE] 65 | } 66 | 67 | .install_filter_r_repos <- 68 | function(pkgs, invert = FALSE) 69 | { 70 | grep("^(https?://.*|[^/]+)$", pkgs, invert = invert, value=TRUE) 71 | } 72 | 73 | .install_filter_up_to_date <- 74 | function(pkgs, instPkgs, old_pkgs, force) 75 | { 76 | if (!force) { 77 | noInst <- !pkgs %in% rownames(old_pkgs) & pkgs %in% rownames(instPkgs) 78 | if (any(noInst)) 79 | .warning( 80 | paste( 81 | "package(s) not installed when version(s) same as or", 82 | "greater than current; use `force = TRUE` to re-install: ", 83 | "\n'%s'" 84 | ), 85 | paste(pkgs[noInst], collapse = "' '") 86 | ) 87 | pkgs <- pkgs[!noInst] 88 | } 89 | pkgs 90 | } 91 | 92 | .install_filter_github_repos <- 93 | function(pkgs) 94 | { 95 | pkgs <- .install_filter_r_repos(pkgs, invert = TRUE) 96 | grep("^[^/]+/.+", pkgs, value=TRUE) 97 | } 98 | 99 | .install_github_load_remotes <- 100 | function(pkgs, lib.loc = NULL) 101 | { 102 | if (!"remotes" %in% rownames(installed.packages(lib.loc))) { 103 | if (is.null(lib.loc)) 104 | lib.loc <- .libPaths() 105 | .stop( 106 | "%s\n %s\n%s", 107 | "package 'remotes' not installed in library path(s)", 108 | paste(lib.loc, collapse="\n "), 109 | "install with 'BiocManager::install(\"remotes\")'", 110 | call. = FALSE, 111 | wrap. = FALSE 112 | ) 113 | } 114 | 115 | tryCatch({ 116 | loadNamespace("remotes", lib.loc) 117 | }, error=function(e) { 118 | .stop( 119 | "'loadNamespace(\"remotes\")' failed:\n %s", 120 | conditionMessage(e), 121 | call. = FALSE, 122 | wrap. = FALSE 123 | ) 124 | }) 125 | 126 | TRUE 127 | } 128 | 129 | .install_repos <- 130 | function(pkgs, old_pkgs, instPkgs, lib, repos, force, ...) 131 | { 132 | doing <- .install_filter_up_to_date( 133 | pkgs = pkgs, instPkgs = instPkgs, old_pkgs = old_pkgs, force = force 134 | ) 135 | up_to_date <- setdiff(pkgs, doing) 136 | doing <- .install_filter_r_repos(doing) 137 | if (length(doing)) { 138 | pkgNames <- paste(.sQuote(doing), collapse=", ") 139 | .message("Installing package(s) %s", pkgNames) 140 | .inet_install.packages(pkgs = doing, lib = lib, repos = repos, ...) 141 | } 142 | setdiff(pkgs, c(doing, up_to_date)) 143 | } 144 | 145 | .install_github <- 146 | function(pkgs, lib, lib.loc, repos, update, ask, force, ...) 147 | { 148 | doing <- .install_filter_github_repos(pkgs) 149 | ask <- if (!update) "never" else if (update && !ask) "always" else "default" 150 | 151 | oopts <- options(repos = repos) # required by remotes:: 152 | on.exit(options(oopts)) 153 | if (length(doing)) { 154 | pkgNames <- paste(.sQuote(doing), collapse=", ") 155 | .message("Installing github package(s) %s", pkgNames) 156 | .install_github_load_remotes(pkgs, lib.loc = lib.loc) 157 | for (repo in doing) 158 | remotes::install_github( 159 | repo, lib = lib, upgrade = ask, force = force, ... 160 | ) 161 | } 162 | setdiff(pkgs, doing) 163 | } 164 | 165 | .install_validate_dots <- 166 | function(..., repos) 167 | { 168 | if (!missing(repos)) 169 | .stop("'repos' argument to 'install()' not allowed") 170 | args <- list(...) 171 | nms <- sum(nzchar(names(args))) 172 | if (nms != length(args)) 173 | .stop("all '...' arguments to 'install()' must be named") 174 | 175 | TRUE 176 | } 177 | 178 | .install_n_invalid_pkgs <- function(valid) { 179 | if (isTRUE(valid)) 180 | 0L 181 | else 182 | sum(nrow(valid$too_new), nrow(valid$out_of_date)) 183 | } 184 | 185 | .install_ask_up_or_down_grade <- 186 | function(version, npkgs, cmp, ask) 187 | { 188 | action <- if (cmp < 0) "Downgrade" else "Upgrade" 189 | txt <- sprintf("%s %d packages to Bioconductor version '%s'? [y/n]: ", 190 | action, npkgs, version) 191 | !ask || .getAnswer(txt, allowed = c("y", "Y", "n", "N")) == "y" 192 | } 193 | 194 | .install <- 195 | function(pkgs, old_pkgs, instPkgs, repos, lib.loc=NULL, lib=.libPaths()[1], 196 | update, ask, force, ...) 197 | { 198 | requireNamespace("utils", quietly=TRUE) || 199 | .stop("failed to load package 'utils'") 200 | 201 | todo <- .install_repos( 202 | pkgs, old_pkgs, instPkgs = instPkgs, lib = lib, repos = repos, 203 | force = force, ... 204 | ) 205 | todo <- .install_github( 206 | todo, lib = lib, lib.loc = lib.loc, repos = repos, 207 | update = update, ask = ask, force = force, ... 208 | ) 209 | 210 | if (length(todo)) 211 | .warning( 212 | "packages not installed (unknown repository)\n '%s'", 213 | paste(.sQuote(todo), collapse = "' '") 214 | ) 215 | 216 | setdiff(pkgs, todo) 217 | } 218 | 219 | .install_update <- 220 | function(repos, ask, lib.loc = NULL, instlib = NULL, checkBuilt, ...) 221 | { 222 | old_pkgs <- .inet_old.packages(lib.loc, repos, checkBuilt = checkBuilt) 223 | if (is.null(old_pkgs)) 224 | return() 225 | 226 | old_pkgs <- .package_filter_masked(old_pkgs) 227 | old_pkgs <- .package_filter_unwriteable(old_pkgs, instlib) 228 | 229 | if (!nrow(old_pkgs)) 230 | return() 231 | 232 | pkgs <- paste(old_pkgs[,"Package"], collapse="', '") 233 | .message("Old packages: '%s'", pkgs) 234 | if (ask) { 235 | answer <- .getAnswer( 236 | "Update all/some/none? [a/s/n]: ", 237 | allowed = c("a", "A", "s", "S", "n", "N") 238 | ) 239 | 240 | if (answer == "n") 241 | return() 242 | 243 | ask <- answer == "s" 244 | } 245 | 246 | .inet_update.packages( 247 | lib.loc, repos, oldPkgs = old_pkgs, ask = ask, instlib = instlib, ... 248 | ) 249 | } 250 | 251 | .install_updated_version <- 252 | function(valid, update, old_pkgs, instPkgs, repos, ask, force, ...) 253 | { 254 | if (isTRUE(valid)) 255 | return(valid) 256 | else 257 | pkgs <- c(rownames(valid$too_new), rownames(valid$out_of_date)) 258 | 259 | if (is.null(pkgs) || !update) 260 | return(pkgs) 261 | 262 | .install( 263 | pkgs, old_pkgs, instPkgs, repos, update = update, 264 | ask = ask, force = force, ... 265 | ) 266 | pkgs 267 | } 268 | 269 | #' @name install 270 | #' @aliases BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS 271 | #' @md 272 | #' 273 | #' @title Install or update Bioconductor, CRAN, and GitHub packages 274 | #' 275 | #' @description The `BiocManager::install()` function installs or 276 | #' updates _Bioconductor_ and CRAN packages in a _Bioconductor_ 277 | #' release. Upgrading to a new _Bioconductor_ release may require 278 | #' additional steps; see \url{https://bioconductor.org/install}. 279 | #' 280 | #' @details 281 | #' 282 | #' Installation of _Bioconductor_ and CRAN packages use R's standard 283 | #' functions for library management -- `install.packages()`, 284 | #' `available.packages()`, `update.packages()`. Installation of GitHub 285 | #' packages uses the `remotes::install_github()`. 286 | #' 287 | #' When installing CRAN or _Bioconductor_ packages, typical arguments 288 | #' include: `lib.loc`, passed to \code{\link{old.packages}()} and used to 289 | #' determine the library location of installed packages to be updated; 290 | #' and `lib`, passed to \code{\link{install.packages}{}} to determine the 291 | #' library location where `pkgs` are to be installed. 292 | #' 293 | #' When installing GitHub packages, `...` is passed to the 294 | #' \pkg{remotes} package functions \code{\link[remotes]{install_github}()} 295 | #' and `remotes:::install()`. A typical use is to build vignettes, via 296 | #' `dependencies=TRUE, build_vignettes=TRUE`. 297 | #' 298 | #' See `?repositories` for additional detail on customizing where 299 | #' BiocManager searches for package installation. 300 | #' 301 | #' \env{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} is an environment 302 | #' variable or global `options()` which, when set to `FALSE`, allows 303 | #' organizations and its users to use offline repositories with BiocManager 304 | #' while enforcing appropriate version checks between _Bioconductor_ and R. 305 | #' Setting \env{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} to `FALSE` can speed 306 | #' package loading when internet access is slow or non-existent, but may 307 | #' result in out-of-date information regarding the current release and 308 | #' development versions of _Bioconductor_. In addition, offline 309 | #' organizations and its users should set the \env{BIOCONDUCTOR_CONFIG_FILE} 310 | #' environment variable or option to a `.yaml` file similar to 311 | #' \url{https://bioconductor.org/config.yaml} for full offline use and 312 | #' version validation. 313 | #' 314 | #' @param pkgs `character()` vector of package names to install or 315 | #' update. A missing value updates installed packages according 316 | #' to `update =` and `ask =`. Package names containing a '/' are 317 | #' treated as GitHub repositories and installed using 318 | #' `remotes::install_github()`. 319 | #' @param ... Additional arguments used by `install.packages()`. 320 | #' @param site_repository (Optional) `character(1)` vector 321 | #' representing an additional repository in which to look for 322 | #' packages to install. This repository will be prepended to the 323 | #' default repositories (which you can see with 324 | #' \code{BiocManager::\link{repositories}()}). 325 | #' @param update `logical(1)`. When `FALSE`, `BiocManager::install()` 326 | #' does not attempt to update old packages. When `TRUE`, update 327 | #' old packages according to `ask`. 328 | #' @param ask `logical(1)` indicating whether to prompt user before 329 | #' installed packages are updated. If TRUE, user can choose 330 | #' whether to update all outdated packages without further 331 | #' prompting, to pick packages to update, or to cancel updating 332 | #' (in a non-interactive session, no packages will be updated 333 | #' unless `ask = FALSE`). 334 | #' @param checkBuilt `logical(1)`. If `TRUE` a package built under an 335 | #' earlier major.minor version of R (e.g., 3.4) is considered to 336 | #' be old. 337 | #' @param force `logical(1)`. If `TRUE` re-download a package that is 338 | #' currently up-to-date. 339 | #' @param version `character(1)` _Bioconductor_ version to install, 340 | #' e.g., `version = "3.8"`. The special symbol `version = "devel"` 341 | #' installs the current 'development' version. 342 | #' 343 | #' @return `BiocManager::install()` returns the `pkgs` argument, invisibly. 344 | #' @seealso 345 | #' 346 | #' \code{BiocManager::\link{repositories}()} returns the _Bioconductor_ and 347 | #' CRAN repositories used by `install()`. 348 | #' 349 | #' \code{\link{install.packages}()} installs the packages themselves (used by 350 | #' `BiocManager::install` internally). 351 | #' 352 | #' \code{\link{update.packages}()} updates all installed packages (used by 353 | #' `BiocManager::install` internally). 354 | #' 355 | #' \code{\link{chooseBioCmirror}()} allows choice of a mirror from all 356 | #' public _Bioconductor_ mirrors. 357 | #' 358 | #' \code{\link{chooseCRANmirror}()} allows choice of a mirror from all 359 | #' public CRAN mirrors. 360 | #' 361 | #' @keywords environment 362 | #' @examples 363 | #' 364 | #' \dontrun{ 365 | #' ## update previously installed packages 366 | #' BiocManager::install() 367 | #' 368 | #' ## install Bioconductor packages, and prompt to update all 369 | #' ## installed packages 370 | #' BiocManager::install(c("GenomicRanges", "edgeR")) 371 | #' 372 | #' ## install a CRAN and Bioconductor packages: 373 | #' BiocManager::install(c("survival", "SummarizedExperiment")) 374 | #' 375 | #' ## install a package from source: 376 | #' BiocManager::install("IRanges", type="source") 377 | #' } 378 | #' 379 | #' @export 380 | install <- 381 | function(pkgs = character(), ..., site_repository = character(), 382 | update = TRUE, ask = TRUE, checkBuilt = FALSE, force = FALSE, 383 | version = BiocManager::version()) 384 | { 385 | stopifnot( 386 | is.character(pkgs), !anyNA(pkgs), 387 | .install_validate_dots(...), 388 | is.logical(update), length(update) == 1L, !is.na(update), 389 | is.logical(ask), length(ask) == 1L, !is.na(ask), 390 | is.logical(checkBuilt), length(checkBuilt) == 1L, !is.na(checkBuilt), 391 | length(version) == 1L || inherits(version, "version_sentinel") 392 | ) 393 | site_repository <- .repositories_site_repository(site_repository) 394 | 395 | version <- .version_validate(version) 396 | 397 | ## use BiocVersion if .version_force_version() is not set; 398 | ## `BiocVersion_pkg` is either "BiocVersion" or NULL. 399 | BiocVersion_pkg <- if (is.na(.version_force_version())) "BiocVersion" 400 | inst <- installed.packages() 401 | if (!"BiocVersion" %in% rownames(inst)) { 402 | pkgs <- unique(c(BiocVersion_pkg, pkgs)) 403 | } 404 | 405 | cmp <- .version_compare(version, version()) 406 | action <- if (cmp < 0) "Downgrade" else "Upgrade" 407 | repos <- .repositories(site_repository, version = version, ...) 408 | 409 | vout <- .valid_out_of_date_pkgs(pkgs = inst, 410 | repos = repos, ..., checkBuilt = checkBuilt, 411 | site_repository = site_repository) 412 | 413 | if (cmp != 0L) { 414 | pkgs <- unique(c(BiocVersion_pkg, pkgs)) 415 | valist <- .valid_result(vout, pkgs = inst) 416 | npkgs <- .install_n_invalid_pkgs(valist) + length(pkgs) 417 | if (!length(pkgs)-1L) { 418 | .install_ask_up_or_down_grade(version, npkgs, cmp, ask) || 419 | .stop(paste0( 420 | "Bioconductor version not changed by 'install()'", 421 | if (!interactive() && isTRUE(ask)) 422 | "; in non-interactive sessions use 'ask = FALSE'" 423 | )) 424 | } else { 425 | fmt <- paste(c( 426 | "To use Bioconductor version '%s', first %s %d packages with", 427 | "\n BiocManager::install(version = '%s')"), 428 | collapse="") 429 | action <- tolower(action) 430 | .stop(fmt, version, action, npkgs, version, wrap.=FALSE) 431 | } 432 | } 433 | 434 | .message(.version_string(version)) 435 | 436 | pkgs <- .install( 437 | pkgs, vout[["out_of_date"]], instPkgs = inst, repos = repos, 438 | update = update, ask = ask, force = force, ... 439 | ) 440 | if (update && cmp == 0L) { 441 | .install_update(repos, ask, checkBuilt = checkBuilt, ...) 442 | } else if (cmp != 0L) { 443 | .install_updated_version( 444 | valist, update, vout[["out_of_date"]], inst, repos, ask = ask, 445 | force = force, ... 446 | ) 447 | } 448 | 449 | invisible(pkgs) 450 | } 451 | -------------------------------------------------------------------------------- /R/repositories.R: -------------------------------------------------------------------------------- 1 | BINARY_BASE_URL <- "https://bioconductor.org/packages/%s/container-binaries/%s" 2 | 3 | .repositories_check_repos_envopt <- 4 | function() 5 | { 6 | opt <- Sys.getenv("BIOCMANAGER_CHECK_REPOSITORIES", TRUE) 7 | opt <- getOption("BiocManager.check_repositories", opt) 8 | isTRUE(as.logical(opt)) 9 | } 10 | 11 | .repositories_site_repository <- 12 | function(site_repository = character()) 13 | { 14 | stopifnot( 15 | length(site_repository) == 0L || .is_scalar_character(site_repository) 16 | ) 17 | if (!length(site_repository) || !nzchar(site_repository)) { 18 | site_repository <- Sys.getenv("BIOCMANAGER_SITE_REPOSITORY", "") 19 | site_repository <- 20 | getOption("BiocManager.site_repository", site_repository) 21 | 22 | if (!nzchar(site_repository)) 23 | site_repository <- character() 24 | } 25 | site_repository 26 | } 27 | 28 | .repositories_check_repos <- 29 | function(repos) 30 | { 31 | conflict <- 32 | names(repos) %in% c(names(.repositories_bioc(version())), "CRAN") 33 | conflict <- conflict & repos != "@CRAN@" 34 | conflicts <- repos[conflict] 35 | 36 | if (length(conflicts)) { 37 | txt <- paste( 38 | "'getOption(\"repos\")' replaces Bioconductor standard ", 39 | "repositories, see ", 40 | "'help(\"repositories\", package = \"BiocManager\")' for details." 41 | ) 42 | fmt <- paste0( 43 | .msg(txt, exdent = 0), 44 | "\nReplacement repositories:", 45 | "\n %s\n" 46 | ) 47 | repos_string <- paste0( 48 | names(conflicts), ": ", unname(conflicts), 49 | collapse = "\n " 50 | ) 51 | if (.repositories_check_repos_envopt()) 52 | .message( 53 | fmt, repos_string, 54 | call. = FALSE, wrap. = FALSE, appendLF = FALSE 55 | ) 56 | } 57 | 58 | repos 59 | } 60 | 61 | .repositories_base <- 62 | function() 63 | { 64 | repos <- getOption("repos") 65 | repos <- .repositories_check_repos(repos) 66 | rename <- repos == "@CRAN@" 67 | repos[rename] <- "https://cloud.r-project.org" 68 | repos 69 | } 70 | 71 | #' @importFrom stats setNames 72 | .repositories_bioc <- 73 | function(version, ..., type = NULL) 74 | { 75 | mirror <- getOption("BioC_mirror", "https://bioconductor.org") 76 | paths <- c( 77 | BioCsoft = "bioc", 78 | BioCann = "data/annotation", 79 | BioCexp = "data/experiment", 80 | BioCworkflows = "workflows", 81 | BioCbooks = if (version() >= "3.12") "books" else character() 82 | ) 83 | bioc_repos <- paste(mirror, "packages", version, paths, sep="/") 84 | c( 85 | containerRepository(version = version, type = type), 86 | setNames(bioc_repos, names(paths)) 87 | ) 88 | } 89 | 90 | .repositories_filter <- 91 | function(repos) 92 | { 93 | ext <- c(".rds", ".gz", "") 94 | pkg_files <- paste0("/PACKAGES", ext) 95 | online <- logical(length(repos)) 96 | for (pkg_file in pkg_files) { 97 | if (all(online)) 98 | next 99 | urls <- paste0(contrib.url(repos[!online]), pkg_file) 100 | online[!online] <- vapply(urls, .url_exists, logical(1)) 101 | } 102 | repos[online] 103 | } 104 | 105 | .repositories <- 106 | function(site_repository, version, ...) 107 | { 108 | base <- .repositories_base() 109 | bioc <- .repositories_bioc(version, ...) 110 | 111 | repos <- c(site_repository = site_repository, bioc, base) 112 | repos[!duplicated(names(repos))] 113 | } 114 | 115 | #' @title Display current Bioconductor and CRAN repositories. 116 | #' 117 | #' @aliases BiocManager.check_repositories 118 | #' 119 | #' @description `repositories()` reports the URLs from which to 120 | #' install _Bioconductor_ and CRAN packages. It is used by 121 | #' `BiocManager::install()` and other functions. 122 | #' 123 | #' @param site_repository (Optional) `character(1)` representing an 124 | #' additional repository (e.g., a URL to an organization's 125 | #' internally maintained repository) in which to look for packages 126 | #' to install. This repository will be prepended to the default 127 | #' repositories returned by the function. 128 | #' 129 | #' @param version (Optional) `character(1)` or `package_version` 130 | #' indicating the _Bioconductor_ version (e.g., "3.8") for which 131 | #' repositories are required. 132 | #' 133 | #' @param ... Additional parameters passed to lower level functions, not 134 | #' used. 135 | #' 136 | #' @param type (Optional) `character(1)` indicating the type of package 137 | #' repository to retrieve (default: "both"). Setting `type` to "source" will 138 | #' disable any Bioconductor binary packages specifically built for the 139 | #' containers. 140 | #' 141 | #' @details 142 | #' 143 | #' `repositories()` returns the appropriate software package 144 | #' repositories for your version of _Bioconductor_. 145 | #' 146 | #' _Bioconductor_ has a 'release' and a 'devel' semi-annual release 147 | #' cycle. Packages within a release have been tested against each 148 | #' other and the current version of packages on CRAN. _Bioconductor_ 149 | #' best practice is to use packages from the same release, and from 150 | #' the appropriate CRAN repository. 151 | #' 152 | #' To install binary packages on containerized versions of Bioconductor, 153 | #' a default binary package location URL is set as a package constant, 154 | #' see `BiocManager:::BINARY_BASE_URL`. Binary package installations 155 | #' are enabled by default for Bioconductor Docker containers. Anyone 156 | #' wishing to opt out of the binary package installation can set either the 157 | #' variable or the option, \env{BIOCONDUCTOR_USE_CONTAINER_REPOSITORY}, to 158 | #' `FALSE`. Note that the availability of Bioconductor package binaries is 159 | #' experimental and binary installations are intended to be used with 160 | #' `bioconductor/bioconductor_docker` images where such installations 161 | #' correspond to specific versions of Linux / Ubuntu. 162 | #' 163 | #' If alternative default repositories are known to provide appropriate 164 | #' versions of CRAN or _Bioconductor_ packages, the message may be silenced 165 | #' by setting either the option or the variable to `FALSE`, i.e., 166 | #' `options(BiocManager.check_repositories = FALSE)` or 167 | #' \env{BIOCMANAGER_CHECK_REPOSITORIES=FALSE}. Alternative default 168 | #' repositories are not guaranteed to work without issues related to 169 | #' incompatible package installations and are used at the user's own risk. 170 | #' 171 | #' The intended use of `site_repository =` is to enable installation of 172 | #' packages not available in the default repositories, e.g., packages 173 | #' internal to an organization and not yet publicly available. A 174 | #' secondary use might provide alternative versions (e.g., compiled 175 | #' binaries) of packages available in the default repositories. Note 176 | #' that _R_'s standard rules of package selection apply, so the most 177 | #' recent version of candidate packages is selected independent of the 178 | #' location of the repository in the vector returned by `repositories()`. 179 | #' To set a more permenanent `site_repository`, one can use either the 180 | #' \env{BIOCMANAGER_SITE_REPOSITORY} environment variable or the 181 | #' `options(BiocManager.site_repository = ...)` option. 182 | #' 183 | #' For greater flexiblity in installing packages while still adhering 184 | #' as much as possible to _Bioconductor_ best practices, use 185 | #' `repositories()` as a basis for constructing the `repos =` argument 186 | #' to `install.packages()` and related functions. 187 | #' 188 | #' @return `repositories()`: named `character()` of repositories. 189 | #' 190 | #' @seealso 191 | #' 192 | #' \code{BiocManager::\link{install}()} Installs or updates Bioconductor, 193 | #' CRAN, and GitHub packages. 194 | #' 195 | #' \code{\link{chooseBioCmirror}()} choose an alternative Bioconductor 196 | #' mirror; not usually necessary. 197 | #' 198 | #' \code{\link{chooseCRANmirror}()} choose an alternative CRAN mirror; not 199 | #' usually necessary. 200 | #' 201 | #' \code{\link{setRepositories}()} Select additional repositories for 202 | #' searching. 203 | #' 204 | #' @keywords environment 205 | #' 206 | #' @examples 207 | #' BiocManager::repositories() 208 | #' \dontrun{ 209 | #' BiocManager::repositories(version="3.8") 210 | #' } 211 | #' 212 | #' @md 213 | #' @export repositories 214 | repositories <- function( 215 | site_repository = character(), 216 | version = BiocManager::version(), 217 | ..., 218 | type = "both" 219 | ) { 220 | site_repository <- .repositories_site_repository(site_repository) 221 | 222 | stopifnot( 223 | length(site_repository) <= 1L, 224 | is.character(site_repository), !anyNA(site_repository) 225 | ) 226 | version <- .version_validate(version) 227 | .repositories(site_repository, version, ..., type = type) 228 | } 229 | 230 | ## is the docker container configured correctly? 231 | .repository_container_version_test <- 232 | function(bioconductor_version, container_version) 233 | { 234 | bioconductor_version <- package_version(bioconductor_version) 235 | docker_version <- package_version(container_version) 236 | (bioconductor_version$major == docker_version$major) && 237 | (bioconductor_version$minor == docker_version$minor) 238 | } 239 | 240 | ## are we running on a docker container? 241 | .repository_container_version <- 242 | function() 243 | { 244 | container_version <- Sys.getenv("BIOCONDUCTOR_DOCKER_VERSION") 245 | if (nzchar(container_version)) { 246 | platform <- Sys.getenv("BIOCONDUCTOR_NAME", "bioconductor_docker") 247 | } else { 248 | platform <- Sys.getenv("TERRA_R_PLATFORM") 249 | container_version <- Sys.getenv("TERRA_R_PLATFORM_BINARY_VERSION") 250 | } 251 | # platform and container_version are zero character vectors 252 | # when not running on a container 253 | list(platform = platform, container_version = container_version) 254 | } 255 | 256 | .repositories_use_container_repo <- 257 | function() 258 | { 259 | opt <- Sys.getenv("BIOCONDUCTOR_USE_CONTAINER_REPOSITORY", TRUE) 260 | opt <- getOption("BIOCONDUCTOR_USE_CONTAINER_REPOSITORY", opt) 261 | isTRUE(as.logical(opt)) 262 | } 263 | 264 | #' @rdname repositories 265 | #' 266 | #' @aliases BINARY_BASE_URL 267 | #' 268 | #' @description `containerRepository()` reports the location of the repository 269 | #' of binary packages for fast installation within containerized versions 270 | #' of Bioconductor, if available. 271 | #' 272 | #' @details 273 | #' 274 | #' The unexported URL to the base repository is available with 275 | #' `BiocManager:::BINARY_BASE_URL`. 276 | #' 277 | #' \env{BIOCONDUCTOR_USE_CONTAINER_REPOSITORY} is an environment 278 | #' variable or global `options()` which, when set to `FALSE`, avoids 279 | #' the fast installation of binary packages within containerized 280 | #' versions of Bioconductor. 281 | #' 282 | #' @return `containerRepository()`: character(1) location of binary repository, 283 | #' if available, or character(0) if not. 284 | #' 285 | #' @examples 286 | #' containerRepository() # character(0) if not within a Bioconductor container 287 | #' 288 | #' @importFrom utils contrib.url 289 | #' 290 | #' @md 291 | #' @export 292 | containerRepository <- 293 | function( 294 | version = BiocManager::version(), type = "binary" 295 | ) 296 | { 297 | if (identical(type, "source")) 298 | return(character()) 299 | platform_docker <- .repository_container_version() 300 | container_version <- platform_docker$container_version 301 | platform <- platform_docker$platform 302 | 303 | ## are we running on a known container? 304 | if (!nzchar(container_version)) 305 | return(character()) 306 | 307 | ## do the versions of BiocManager::version() and the container match? 308 | versions_match <- .repository_container_version_test( 309 | version, container_version 310 | ) 311 | if (!versions_match) 312 | return(character()) 313 | 314 | if (!.repositories_use_container_repo()) 315 | return(character()) 316 | 317 | ## does the binary repository exist? 318 | binary_repos0 <- sprintf(BINARY_BASE_URL, version, platform) 319 | packages <- paste0(contrib.url(binary_repos0), "/PACKAGES.gz") 320 | url <- url(packages) 321 | tryCatch({ 322 | suppressWarnings(open(url, "rb")) 323 | close(url) 324 | setNames(binary_repos0, "BioCcontainers") 325 | }, error = function(...) { 326 | close(url) 327 | character() 328 | }) 329 | } 330 | -------------------------------------------------------------------------------- /R/utilities.R: -------------------------------------------------------------------------------- 1 | .is_CRAN_check <- 2 | function() 3 | { 4 | !interactive() && ("CheckExEnv" %in% search()) 5 | } 6 | 7 | .is_character <- 8 | function(x, na.ok = FALSE, zchar = FALSE) 9 | { 10 | is.character(x) && 11 | (na.ok || all(!is.na(x))) && 12 | (zchar || all(nzchar(x))) 13 | } 14 | 15 | .is_scalar_character <- function(x, na.ok = FALSE, zchar = FALSE) 16 | length(x) == 1L && .is_character(x, na.ok, zchar) 17 | 18 | .is_scalar_logical <- function(x, na.ok = FALSE) 19 | is.logical(x) && length(x) == 1L && (na.ok || !is.na(x)) 20 | 21 | .getAnswer <- function(msg, allowed) 22 | { 23 | if (interactive()) { 24 | repeat { 25 | cat(msg) 26 | answer <- readLines(n = 1) 27 | if (answer %in% allowed) 28 | break 29 | } 30 | tolower(answer) 31 | } else { 32 | "n" 33 | } 34 | } 35 | 36 | .sQuote <- function(x) 37 | sprintf("'%s'", as.character(x)) 38 | 39 | .url_exists <- 40 | function(url) 41 | { 42 | suppressWarnings(tryCatch({ 43 | identical(nchar(.inet_readChar(url, 1L)), 1L) 44 | }, error = function(...) { 45 | FALSE 46 | })) 47 | } 48 | 49 | .msg <- 50 | function( 51 | fmt, ..., 52 | width=getOption("width"), indent = 0, exdent = 2, wrap. = TRUE 53 | ) 54 | ## Use this helper to format all error / warning / message text 55 | { 56 | txt <- sprintf(fmt, ...) 57 | if (wrap.) { 58 | txt <- strwrap( 59 | sprintf(fmt, ...), width=width, indent = indent, exdent=exdent 60 | ) 61 | paste(txt, collapse="\n") 62 | } else { 63 | txt 64 | } 65 | } 66 | 67 | .message <- 68 | function(..., call. = FALSE, domain = NULL, appendLF=TRUE) 69 | { 70 | ## call. = FALSE provides compatibility with .stop(), but is ignored 71 | message(.msg(...), domain = NULL, appendLF=appendLF) 72 | invisible(TRUE) 73 | } 74 | 75 | .packageStartupMessage <- 76 | function(..., domain = NULL, appendLF = TRUE) 77 | { 78 | packageStartupMessage(.msg(...), domain = domain, appendLF = appendLF) 79 | invisible(TRUE) 80 | } 81 | 82 | .stop <- 83 | function(..., call.=FALSE) 84 | { 85 | stop(.msg(...), call.=call.) 86 | } 87 | 88 | .warning <- 89 | function(..., call.=FALSE, immediate.=FALSE) 90 | { 91 | warning(.msg(...), call.=call., immediate.=immediate.) 92 | invisible(TRUE) 93 | } 94 | 95 | isDevel <- 96 | function() 97 | { 98 | version() == .version_bioc("devel") 99 | } 100 | 101 | isRelease <- 102 | function() 103 | { 104 | version() == .version_bioc("release") 105 | } 106 | 107 | ## testthat helper functions 108 | 109 | .skip_if_misconfigured <- 110 | function() 111 | { 112 | R_version <- getRversion() 113 | bioc_version <- version() 114 | 115 | test_ver <- tryCatch({ 116 | .version_validity(bioc_version) 117 | }, error = function(err) { 118 | conditionMessage(err) 119 | }) 120 | 121 | if (!isTRUE(test_ver)) { 122 | msg <- sprintf( 123 | "mis-configuration, R %s, Bioconductor %s", R_version, bioc_version 124 | ) 125 | testthat::skip(msg) 126 | } 127 | } 128 | 129 | .skip_if_BiocVersion_not_available <- 130 | function() 131 | { 132 | if (!"BiocVersion" %in% rownames(installed.packages())) 133 | testthat::skip("BiocVersion not installed") 134 | } 135 | -------------------------------------------------------------------------------- /R/valid.R: -------------------------------------------------------------------------------- 1 | .valid_pkgs_too_new <- 2 | function(instPkgs, availPkgs) 3 | { 4 | idx <- rownames(availPkgs) %in% rownames(instPkgs) 5 | vers <- availPkgs[idx, "Version"] 6 | idx <- package_version(vers) < 7 | package_version(instPkgs[names(vers), "Version"]) 8 | too_new <- names(vers)[idx] 9 | instPkgs[too_new, c("Version", "LibPath"), drop=FALSE] 10 | } 11 | 12 | .valid_out_of_date_pkgs <- 13 | function(pkgs = installed.packages(lib.loc, priority=priority), repos, 14 | lib.loc=NULL, priority="NA", type=getOption("pkgType"), 15 | filters=NULL, ..., checkBuilt, site_repository) 16 | { 17 | contribUrl <- contrib.url(repos, type=type) 18 | 19 | available <- out_of_date <- too_new <- character() 20 | result <- FALSE 21 | available <- .inet_available.packages( 22 | contribUrl, type=type, filters=filters 23 | ) 24 | out_of_date <- .inet_old.packages( 25 | lib.loc, repos=repos, instPkgs=pkgs, 26 | available=available, checkBuilt=checkBuilt, type=type 27 | ) 28 | list( 29 | available = available, 30 | out_of_date = out_of_date, 31 | noRepos = !length(repos) 32 | ) 33 | } 34 | 35 | .valid_out_of_date_filter <- function(out_of_date) { 36 | out_of_date[rownames(out_of_date) != "BiocVersion", , drop = FALSE] 37 | } 38 | 39 | .valid_result <- 40 | function(avail_out, pkgs = installed.packages(lib.loc, priority=priority), 41 | lib.loc=NULL, priority="NA") 42 | { 43 | too_new <- .valid_pkgs_too_new(pkgs, avail_out[["available"]]) 44 | out_of_date <- .valid_out_of_date_filter(avail_out[["out_of_date"]]) 45 | 46 | result <- !nrow(too_new) && (is.null(out_of_date) || !nrow(out_of_date)) 47 | 48 | if (!result || avail_out[["noRepos"]]) { 49 | result <- structure( 50 | list(out_of_date = out_of_date, too_new = too_new), 51 | class="biocValid" 52 | ) 53 | } 54 | result 55 | } 56 | 57 | #' Validate installed package versions against correct versions. 58 | #' 59 | #' Check that installed packages are consistent (neither out-of-date 60 | #' nor too new) with the version of R and _Bioconductor_ in use. 61 | #' 62 | #' @details This function compares the version of installed packages 63 | #' to the version of packages associated with the version of _R_ 64 | #' and _Bioconductor_ currently in use. 65 | #' 66 | #' Packages are reported as 'out-of-date' if a more recent version 67 | #' is available at the repositories specified by 68 | #' `BiocManager::repositories()`. Usually, `BiocManager::install()` is 69 | #' sufficient to update packages to their most recent version. 70 | #' 71 | #' Packages are reported as 'too new' if the installed version is 72 | #' more recent than the most recent available in the 73 | #' `BiocManager::repositories()`. It is possible to down-grade by 74 | #' re-installing a too new package "PkgA" with 75 | #' `BiocManger::install("PkgA")`. It is important for the user to 76 | #' understand how their installation became too new, and to avoid 77 | #' this in the future. 78 | #' 79 | #' @param pkgs A character() vector of package names for checking, or 80 | #' a matrix as returned by \code{\link{installed.packages}()}`. 81 | #' @param lib.loc A character() vector of library location(s) of 82 | #' packages to be validated; see \code{\link{installed.packages}()}. 83 | #' @param priority character(1) Check validity of all, "base", or 84 | #' "recommended" packages; see \code{\link{installed.packages}()}. 85 | #' @param type character(1) The type of available package (e.g., 86 | #' binary, source) to check validity against; see 87 | #' \code{\link{available.packages}()}. 88 | #' @param filters character(1) Filter available packages to check 89 | #' validity against; see \code{\link{available.packages}()}. 90 | #' @param \dots Additional arguments, passed to 91 | #' \code{BiocManager::\link{install}()} when `fix=TRUE`. 92 | #' @param checkBuilt `logical(1)`. If `TRUE` a package built under an 93 | #' earlier major.minor version of R (e.g., 3.4) is considered to 94 | #' be old. 95 | #' @param site_repository `character(1)`. See `?install`. 96 | #' @return `biocValid` list object with elements `too_new` and 97 | #' `out_of_date` containing `data.frame`s with packages and their 98 | #' installed locations that are too new or out-of-date for the 99 | #' current version of _Bioconductor_. When internet access 100 | #' is unavailable, an empty 'biocValid' list is returned. If all 101 | #' packages ('pkgs') are up to date, then TRUE is returned. 102 | #' @author Martin Morgan \email{martin.morgan@@roswellpark.org} 103 | #' @seealso \code{BiocManager::\link{install}()} to update installed 104 | #' packages. 105 | #' @keywords environment 106 | #' @examples 107 | #' if (interactive()) { 108 | #' BiocManager::valid() 109 | #' } 110 | #' @md 111 | #' @export valid 112 | valid <- 113 | function(pkgs = installed.packages(lib.loc, priority=priority), 114 | lib.loc=NULL, priority="NA", type=getOption("pkgType"), 115 | filters=NULL, ..., checkBuilt = FALSE, 116 | site_repository = character()) 117 | { 118 | stopifnot( 119 | is.logical(checkBuilt), length(checkBuilt) == 1L, !is.na(checkBuilt) 120 | ) 121 | site_repository <- .repositories_site_repository(site_repository) 122 | 123 | if (!is.matrix(pkgs)) { 124 | if (is.character(pkgs)) { 125 | pkgs <- installed.packages(pkgs, lib.loc=lib.loc) 126 | } else { 127 | .stop( 128 | "'pkgs' must be a character vector of package names, 129 | or a matrix like that returned by 'installed.packages()'" 130 | ) 131 | } 132 | } 133 | version <- .version_validate(version()) 134 | repos <- .repositories(site_repository, version = version) 135 | repos <- .repositories_filter(repos) 136 | 137 | vout <- .valid_out_of_date_pkgs(pkgs = pkgs, lib.loc = lib.loc, 138 | repos = repos, priority = priority, type = type, filters=filters, ..., 139 | checkBuilt = checkBuilt, site_repository = site_repository) 140 | 141 | result <- 142 | .valid_result(vout, pkgs = pkgs, lib.loc = lib.loc, priority = priority) 143 | 144 | if (!isTRUE(result)) { 145 | out_of_date <- result$out_of_date 146 | too_new <- result$too_new 147 | if (NROW(out_of_date) + NROW(too_new) != 0L) { 148 | .warning( 149 | "%d packages out-of-date; %d packages too new", 150 | NROW(out_of_date), NROW(too_new) 151 | ) 152 | } 153 | } 154 | result 155 | } 156 | 157 | #' @rdname valid 158 | #' @param x A `biocValid` object returned by `BiocManager::valid()`. 159 | #' @return `print()` is invoked for its side effect. 160 | #' @export 161 | print.biocValid <- 162 | function(x, ...) 163 | { 164 | cat("\n* sessionInfo()\n\n") 165 | print(sessionInfo()) 166 | 167 | cat( 168 | "\nBioconductor version '", as.character(version()), "'", 169 | "\n", 170 | "\n * ", NROW(x$out_of_date), " packages out-of-date", 171 | "\n * ", NROW(x$too_new), " packages too new", 172 | sep = "" 173 | ) 174 | 175 | n <- NROW(x$too_new) + NROW(x$out_of_date) 176 | if (n == 0L) { 177 | cat("\n\nInstallation valid\n") 178 | return() 179 | } 180 | 181 | fmt <-' BiocManager::install(%s, update = TRUE, ask = FALSE, force = TRUE)' 182 | if (n == 1L) { 183 | fmt <- sprintf(fmt, '"%s"') 184 | } else { 185 | fmt <- sprintf(fmt, 'c(\n "%s"\n )') 186 | } 187 | 188 | pkgs0 <- sort(unique(c(rownames(x$too_new), rownames(x$out_of_date)))) 189 | pkgs <- paste(strwrap( 190 | paste(pkgs0, collapse='", "'), 191 | width = getOption("width") - 4L 192 | ), collapse="\n ") 193 | cat( 194 | "\n\ncreate a valid installation with", 195 | "\n\n", sprintf(fmt, pkgs), "\n\n", 196 | sep = "" 197 | ) 198 | cat("more details: BiocManager::valid()$too_new, BiocManager::valid()$out_of_date\n\n") 199 | } 200 | -------------------------------------------------------------------------------- /R/version.R: -------------------------------------------------------------------------------- 1 | .VERSION_HELP <- "see https://bioconductor.org/install" 2 | 3 | .VERSION_UNKNOWN <- 4 | "Bioconductor version cannot be determined; no internet connection? 5 | See #troubleshooting section in vignette" 6 | 7 | .VERSION_MAP_UNABLE_TO_VALIDATE <- 8 | "Bioconductor version cannot be validated; no internet connection? 9 | See #troubleshooting section in vignette" 10 | 11 | .VERSION_MAP_MISCONFIGURATION <- 12 | "Bioconductor version map cannot be validated; is it misconfigured? 13 | See #troubleshooting section in vignette" 14 | 15 | .VERSION_TYPE_MISSPECIFICATION <- 16 | "Bioconductor version cannot be validated; is type input misspecified? 17 | See #troubleshooting section in vignette" 18 | 19 | .NO_ONLINE_VERSION_DIAGNOSIS <- 20 | "Bioconductor online version validation disabled; 21 | see ?BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS" 22 | 23 | .VERSION_TAGS <- 24 | c("out-of-date", "release", "devel", "future") 25 | 26 | .VERSION_MAP_SENTINEL <- data.frame( 27 | Bioc = package_version(character()), 28 | R = package_version(character()), 29 | BiocStatus = factor( 30 | factor(), 31 | levels = .VERSION_TAGS 32 | ) 33 | ) 34 | 35 | ## version-specific options 36 | 37 | .version_force_version <- 38 | function() 39 | { 40 | ## check R_BIOC_VERSION environment variable 41 | force_version <- Sys.getenv("R_BIOC_VERSION", "") 42 | 43 | ## return either NA (do no force version) or the version to use 44 | if (nzchar(force_version)) { 45 | package_version(force_version) 46 | } else { 47 | NA 48 | } 49 | } 50 | 51 | .version_sentinel <- 52 | function(msg) 53 | { 54 | version <- package_version(NA_character_, strict = FALSE) 55 | structure( 56 | unclass(version), 57 | msg = msg, 58 | class = c("version_sentinel", class(version)) 59 | ) 60 | } 61 | 62 | .version_sentinel_msg <- 63 | function(x) 64 | { 65 | attr(x, "msg") 66 | } 67 | 68 | #' @export 69 | format.version_sentinel <- 70 | function(x, ...) 71 | { 72 | paste0("unknown version: ", .version_sentinel_msg(x)) 73 | } 74 | 75 | .version_compare <- 76 | function(v1, v2) 77 | { 78 | ## return -1, 0, or 1 when v1 is <, ==, or > v2 79 | if (v1 < v2) 80 | -1L 81 | else if (v1 > v2) 82 | 1L 83 | else 0L 84 | } 85 | 86 | .VERSION_MAP <- local({ 87 | WARN_NO_ONLINE_CONFIG <- TRUE 88 | environment() 89 | }) 90 | 91 | .version_validity_online_check <- 92 | function() 93 | { 94 | opt <- Sys.getenv("BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS", TRUE) 95 | opt <- getOption("BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS", opt) 96 | opt <- isTRUE(as.logical(opt)) 97 | 98 | if (.VERSION_MAP$WARN_NO_ONLINE_CONFIG && !opt) { 99 | .VERSION_MAP$WARN_NO_ONLINE_CONFIG <- FALSE 100 | .warning(.NO_ONLINE_VERSION_DIAGNOSIS) 101 | } 102 | opt 103 | } 104 | 105 | .version_map_get_online_config <- 106 | function(config) 107 | { 108 | txt <- tryCatch(.inet_readLines(config), error = identity) 109 | if (inherits(txt, "error")) { 110 | if (startsWith(config, "https://")) 111 | config <- sub("https", "http", config) 112 | else if (!startsWith(config, "http")) 113 | config <- paste0("file://", config) 114 | txt <- tryCatch(.inet_readLines(config), error = identity) 115 | } 116 | txt 117 | } 118 | 119 | .version_map_config_element <- 120 | function(txt, tag) 121 | { 122 | grps <- grep("^[^[:blank:]]", txt) 123 | start <- match(grep(tag, txt), grps) 124 | if (!length(start)) 125 | return(setNames(character(), character())) 126 | end <- ifelse(length(grps) < start + 1L, length(txt), grps[start + 1] - 1L) 127 | map <- txt[seq(grps[start] + 1, end)] 128 | map <- trimws(gsub("\"", "", sub(" #.*", "", map))) 129 | 130 | pattern <- "(.*): (.*)" 131 | key <- sub(pattern, "\\1", map) 132 | value <- sub(pattern, "\\2", map) 133 | setNames(value, key) 134 | } 135 | 136 | .version_map_get_online <- 137 | function(config) 138 | { 139 | toggle_warning <- FALSE 140 | withCallingHandlers({ 141 | txt <- .version_map_get_online_config(config) 142 | }, warning = function(w) { 143 | if (!.VERSION_MAP$WARN_NO_ONLINE_CONFIG) 144 | invokeRestart("muffleWarning") 145 | toggle_warning <<- TRUE 146 | }) 147 | if (toggle_warning) 148 | .VERSION_MAP$WARN_NO_ONLINE_CONFIG <- FALSE 149 | 150 | if (!length(txt) || inherits(txt, "error")) 151 | return(.VERSION_MAP_SENTINEL) 152 | 153 | bioc_r_map <- .version_map_config_element(txt, "r_ver_for_bioc_ver") 154 | if (!length(bioc_r_map)) 155 | return(.VERSION_MAP_SENTINEL) 156 | bioc <- package_version(names(bioc_r_map)) 157 | r <- package_version(unname(bioc_r_map)) 158 | 159 | pattern <- "^release_version: \"(.*)\"" 160 | release <- package_version( 161 | sub(pattern, "\\1", grep(pattern, txt, value=TRUE)) 162 | ) 163 | pattern <- "^devel_version: \"(.*)\"" 164 | devel <- package_version( 165 | sub(pattern, "\\1", grep(pattern, txt, value=TRUE)) 166 | ) 167 | status <- rep("out-of-date", length(bioc)) 168 | status[bioc == release] <- "release" 169 | status[bioc == devel] <- "devel" 170 | 171 | ## append final version for 'devel' R 172 | bioc <- c( 173 | bioc, max(bioc) 174 | ## package_version(paste(unlist(max(bioc)) + 0:1, collapse = ".")) 175 | ) 176 | if (max(r) == package_version("3.6")) { 177 | future_r <- package_version("4.0") 178 | } else { 179 | future_r <- package_version(paste(unlist(max(r)) + 0:1, collapse = ".")) 180 | } 181 | r <- c(r, future_r) 182 | status <- c(status, "future") 183 | 184 | rbind(.VERSION_MAP_SENTINEL, data.frame( 185 | Bioc = bioc, R = r, 186 | BiocStatus = factor( 187 | status, 188 | levels = .VERSION_TAGS 189 | ) 190 | )) 191 | } 192 | 193 | .version_map_get_offline <- 194 | function() 195 | { 196 | bioc <- .version_BiocVersion() 197 | if (is.na(bioc)) 198 | return(.VERSION_MAP_SENTINEL) 199 | 200 | r <- .version_R_version()[,1:2] 201 | 202 | status <- .VERSION_TAGS 203 | rbind(.VERSION_MAP_SENTINEL, data.frame( 204 | Bioc = bioc, R = r, 205 | BiocStatus = factor( 206 | NA, 207 | levels = status 208 | ) 209 | )) 210 | } 211 | 212 | .version_map_get <- 213 | function(config = NULL) 214 | { 215 | if (!.version_validity_online_check()) 216 | .version_map_get_offline() 217 | else { 218 | if (is.null(config) || !nchar(config)) 219 | config <- "https://bioconductor.org/config.yaml" 220 | .version_map_get_online(config) 221 | } 222 | } 223 | 224 | .version_map <- local({ 225 | version_map <- .VERSION_MAP_SENTINEL 226 | function() { 227 | config <- Sys.getenv("BIOCONDUCTOR_CONFIG_FILE") 228 | config <- getOption("BIOCONDUCTOR_CONFIG_FILE", config) 229 | if (identical(version_map, .VERSION_MAP_SENTINEL)) 230 | version_map <<- .version_map_get(config) 231 | version_map 232 | } 233 | }) 234 | 235 | .version_field <- 236 | function(field) 237 | { 238 | map <- .version_map() 239 | if (identical(map, .VERSION_MAP_SENTINEL)) 240 | return(NA) 241 | idx <- match(version(), map[["Bioc"]]) 242 | map[idx, field] 243 | } 244 | 245 | .version_R_version <- function() 246 | getRversion() 247 | 248 | .version_BiocVersion_installed <- function() 249 | nzchar(system.file(package = "BiocVersion")) 250 | 251 | .version_BiocVersion <- 252 | function() 253 | { 254 | if (.version_BiocVersion_installed()) 255 | packageVersion("BiocVersion")[, 1:2] 256 | else 257 | .version_sentinel("BiocVersion is not installed") 258 | } 259 | 260 | .version_string <- 261 | function(bioc_version = version()) 262 | { 263 | sprintf( 264 | "Bioconductor version %s (BiocManager %s), %s", 265 | bioc_version, packageVersion("BiocManager"), 266 | sub(" version", "", R.version.string) 267 | ) 268 | } 269 | 270 | ## .version_validity() returns TRUE if the version is valid for this 271 | ## version of R, or a text string (created with sprintf()) explaining why 272 | ## the version is invalid. It does NOT call message / warning / etc 273 | ## directly. 274 | .version_validity <- 275 | function(version, map = .version_map(), r_version = .version_R_version(), 276 | check_future = FALSE) 277 | { 278 | if (!is.na(.version_force_version())) { 279 | return(sprintf( 280 | "Using environment variable R_BIOC_VERSION = '%s'", 281 | version 282 | )) 283 | } 284 | if (identical(version, "devel")) 285 | version <- .version_bioc("devel") 286 | version <- .package_version(version) 287 | 288 | if (inherits(version, "version_sentinel")) 289 | return(.version_sentinel_msg(version)) 290 | 291 | if (version[, 1:2] != version) 292 | return(sprintf( 293 | "version '%s' must have two components, e.g., '3.7'", version 294 | )) 295 | 296 | if (identical(map, .VERSION_MAP_SENTINEL)) 297 | return(.VERSION_MAP_UNABLE_TO_VALIDATE) 298 | 299 | if (!all(.VERSION_TAGS %in% map$BiocStatus)) 300 | return(.VERSION_MAP_MISCONFIGURATION) 301 | 302 | if (!version %in% map$Bioc) 303 | return(sprintf( 304 | "unknown Bioconductor version '%s'; %s", version, .VERSION_HELP 305 | )) 306 | 307 | required <- map$R[map$Bioc == version & !map$BiocStatus %in% "future"] 308 | r_version <- r_version[, 1:2] 309 | if (!r_version %in% required) { 310 | rec <- map[map$R == r_version, , drop = FALSE] 311 | one_up <- required 312 | one_up[, 2] <- as.integer(required[, 2]) + 1L 313 | if (r_version == one_up && "future" %in% rec$BiocStatus) { 314 | if (check_future) { 315 | return(sprintf( 316 | "Bioconductor does not yet build and check packages for R 317 | version %s, using unsupported Bioconductor version %s; %s", 318 | r_version, version, .VERSION_HELP 319 | )) 320 | } 321 | } else { 322 | rec_fun <- ifelse("devel" %in% rec$BiocStatus, head, tail) 323 | rec_msg <- sprintf( 324 | "use `version = '%s'` with R version %s", 325 | rec_fun(rec$Bioc, 1), r_version 326 | ) 327 | 328 | return(sprintf( 329 | "Bioconductor version '%s' requires R version '%s'; %s; %s", 330 | version, head(required, 1), rec_msg, .VERSION_HELP 331 | )) 332 | } 333 | } 334 | 335 | TRUE 336 | } 337 | 338 | .version_validate <- 339 | function(version) 340 | { 341 | if (identical(version, "devel")) 342 | version <- .version_bioc("devel") 343 | version <- .package_version(version) 344 | force_version <- .version_force_version() 345 | if (identical(version, force_version)) 346 | return(version) 347 | 348 | txt <- .version_validity(version) 349 | isTRUE(txt) || ifelse(.is_CRAN_check(), .message(txt), .stop(txt)) 350 | 351 | version 352 | } 353 | 354 | .r_version_lt_350 <- 355 | function() 356 | { 357 | getRversion() < package_version("3.5.0") 358 | } 359 | 360 | .version_recommend <- 361 | function(version) 362 | { 363 | release <- .version_bioc("release") 364 | if (is.package_version(release) && version < release) { 365 | if (.r_version_lt_350()) 366 | return(sprintf( 367 | "Bioconductor version '%s' is out-of-date; BiocManager does 368 | not support R version '%s'. Older installations of 369 | Bioconductor are no longer supported as the 'BiocInstaller' 370 | script has been defunct. Use an R version greater than '3.5' 371 | and install the latest version of Bioconductor with 372 | 'BiocManager'.", 373 | version, getRversion() 374 | )) 375 | else 376 | return(sprintf( 377 | "Bioconductor version '%s' is out-of-date; the current release 378 | version '%s' is available with R version '%s'; %s", 379 | version, release, .version_R("release"), .VERSION_HELP 380 | )) 381 | } 382 | 383 | TRUE 384 | } 385 | 386 | .version_choose_best <- 387 | function() 388 | { 389 | map <- .version_map() 390 | if (identical(map, .VERSION_MAP_SENTINEL)) 391 | return(.version_sentinel(.VERSION_MAP_UNABLE_TO_VALIDATE)) 392 | 393 | if (!all(.VERSION_TAGS %in% map$BiocStatus)) 394 | return(.version_sentinel(.VERSION_MAP_MISCONFIGURATION)) 395 | 396 | map <- map[map$R == getRversion()[, 1:2],] 397 | if ("release" %in% map$BiocStatus) 398 | idx <- map$BiocStatus == "release" 399 | else if ("devel" %in% map$BiocStatus) 400 | idx <- map$BiocStatus == "devel" 401 | else if ("out-of-date" %in% map$BiocStatus) 402 | idx <- map$BiocStatus == "out-of-date" 403 | else 404 | idx <- map$BiocStatus == "future" 405 | 406 | tail(map$Bioc[idx], 1) 407 | } 408 | 409 | .version_bioc <- 410 | function(type) 411 | { 412 | map <- .version_map() 413 | if (identical(map, .VERSION_MAP_SENTINEL)) 414 | return(.VERSION_MAP_UNABLE_TO_VALIDATE) 415 | 416 | if (!all(.VERSION_TAGS %in% map$BiocStatus)) 417 | return(.VERSION_MAP_MISCONFIGURATION) 418 | 419 | if (!type %in% .VERSION_TAGS) 420 | return(.VERSION_TYPE_MISSPECIFICATION) 421 | 422 | version <- map$Bioc[map$BiocStatus == type] 423 | if (!length(version) || is.na(version)) 424 | version <- .VERSION_UNKNOWN 425 | version 426 | } 427 | 428 | .version_R <- 429 | function(type) 430 | { 431 | map <- .version_map() 432 | if (identical(map, .VERSION_MAP_SENTINEL)) 433 | return(.VERSION_MAP_UNABLE_TO_VALIDATE) 434 | 435 | if (!all(.VERSION_TAGS %in% map$BiocStatus)) 436 | return(.VERSION_MAP_MISCONFIGURATION) 437 | 438 | if (!type %in% .VERSION_TAGS) 439 | return(.VERSION_TYPE_MISSPECIFICATION) 440 | 441 | version <- map$R[map$BiocStatus == type] 442 | if (!length(version) || is.na(version)) 443 | version <- .VERSION_UNKNOWN 444 | version 445 | } 446 | 447 | #' Version of Bioconductor currently in use. 448 | #' 449 | #' `version()` reports the version of _Bioconductor_ appropropriate 450 | #' for this version of R, or the version of _Bioconductor_ requested 451 | #' by the user. 452 | #' 453 | #' `version()` (and all functions requiring version information) fails 454 | #' when version cannot be validated e.g., because internet access is 455 | #' not available. 456 | #' 457 | #' The environment variable `R_BIOC_VERSION` can be used to specify a 458 | #' version that is not consistent with *Bioconductor* release 459 | #' versioning. Use of this variable is strongly discouraged. 460 | #' 461 | #' @return A two-digit version, e.g., `3.8`, of class 462 | #' `package_version` describing the version of _Bioconductor_ in 463 | #' use. 464 | #' 465 | #' @md 466 | #' @examples 467 | #' BiocManager::version() 468 | #' 469 | #' @export 470 | version <- 471 | function() 472 | { 473 | bioc <- .version_force_version() 474 | if (is.na(bioc)) 475 | bioc <- .version_BiocVersion() 476 | if (is.na(bioc)) 477 | bioc <- .version_choose_best() 478 | 479 | bioc 480 | } 481 | 482 | .package_version <- 483 | function(x) 484 | { 485 | if (!inherits(x, "package_version")) # preserved full class attributes 486 | x <- package_version(x) 487 | x 488 | } 489 | 490 | #' @rdname version 491 | #' 492 | #' @param x An `unknown_version` instance used to represent the 493 | #' situation when the version of Bioconductor in use cannot be 494 | #' determined. 495 | #' 496 | #' @param ... Additional arguments, ignored. 497 | #' 498 | #' @md 499 | #' @export 500 | print.version_sentinel <- 501 | function(x, ...) 502 | { 503 | cat(format(x), "\n", sep = "") 504 | } 505 | -------------------------------------------------------------------------------- /R/zzz.R: -------------------------------------------------------------------------------- 1 | .onAttach <- 2 | function(libname, pkgname) 3 | { 4 | version <- version() 5 | 6 | validity <- .version_validity(version, check_future = TRUE) 7 | isTRUE(validity) || .packageStartupMessage(validity) 8 | 9 | if (interactive() && isTRUE(validity)) 10 | .packageStartupMessage(.version_string(version)) 11 | 12 | recommend <- .version_recommend(version) 13 | isTRUE(recommend) || .packageStartupMessage(recommend) 14 | } 15 | -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | ```{r, include=FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | out.width = "100%" 12 | ) 13 | ``` 14 | 15 | # BiocManager BiocManager CRAN landing page 16 | 17 | 18 | [![CRAN status](https://www.r-pkg.org/badges/version/BiocManager)](https://cran.r-project.org/package=BiocManager) 19 | [![CRAN release](http://www.r-pkg.org/badges/version-last-release/BiocManager)](https://github.com/Bioconductor/BiocManager/releases) 20 | [![CRAN downloads](http://cranlogs.r-pkg.org/badges/BiocManager)](https://cran.r-project.org/package=BiocManager) 21 | 22 | 23 | ## Overview 24 | 25 | The `BiocManager` package allows users to install and manage packages 26 | from the _[Bioconductor][1]_ project, including CRAN packages that 27 | depend or import Bioconductor packages. Bioconductor focuses on the 28 | statistical analysis and comprehension of high-throughput genomic 29 | data. 30 | 31 | Current _Bioconductor_ packages are available on a 'release' version intended 32 | for every-day use, and a 'devel' version where new features are continually 33 | introduced. A new release version is created every six months. Using the 34 | `BiocManager` package helps users accurately install packages from the 35 | appropriate release. 36 | 37 | * `available()` shows all packages associated with a search pattern 38 | * `install()` installs and/or updates packages either CRAN or Bioconductor 39 | * `repositories()` shows all package repository URL endpoints 40 | * `valid()` checks and returns packages that are out-of-date or too new 41 | * `version()` returns the current Bioconductor version number 42 | 43 | ## Installation 44 | 45 | ```{r, eval = FALSE} 46 | if (!requireNamespace("BiocManager", quietly = TRUE)) 47 | install.packages("BiocManager", repos = "https://cran.R-project.org") 48 | ``` 49 | 50 | ## Usage 51 | 52 | ### Checking Bioconductor version currently in use 53 | 54 | ```{r, message=FALSE} 55 | BiocManager::version() 56 | ``` 57 | 58 | ### Installing Bioconductor packages 59 | 60 | ```{r, eval=FALSE} 61 | BiocManager::install(c("GenomicRanges", "SummarizedExperiment")) 62 | ``` 63 | 64 | ### Verifying a valid Bioconductor installation 65 | 66 | ```{r} 67 | BiocManager::valid() 68 | ``` 69 | 70 | ## More information 71 | 72 | Please see the 'Get started' document (package vignette) for more 73 | detailed information such as changing Bioconductor version, offline 74 | use, and other advanced usage. 75 | 76 | ## Getting help 77 | 78 | To report apparent bugs, create a minimal and reproducible example on 79 | [GitHub][2]. 80 | 81 | [1]: https://bioconductor.org 82 | [2]: https://github.com/Bioconductor/BiocManager/issues 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | # BiocManager BiocManager CRAN landing page 5 | 6 | 7 | 8 | [![CRAN 9 | status](https://www.r-pkg.org/badges/version/BiocManager)](https://cran.r-project.org/package=BiocManager) 10 | [![CRAN 11 | release](http://www.r-pkg.org/badges/version-last-release/BiocManager)](https://github.com/Bioconductor/BiocManager/releases) 12 | [![CRAN 13 | downloads](http://cranlogs.r-pkg.org/badges/BiocManager)](https://cran.r-project.org/package=BiocManager) 14 | 15 | 16 | ## Overview 17 | 18 | The `BiocManager` package allows users to install and manage packages 19 | from the *[Bioconductor](https://bioconductor.org)* project, including 20 | CRAN packages that depend or import Bioconductor packages. Bioconductor 21 | focuses on the statistical analysis and comprehension of high-throughput 22 | genomic data. 23 | 24 | Current *Bioconductor* packages are available on a ‘release’ version 25 | intended for every-day use, and a ‘devel’ version where new features are 26 | continually introduced. A new release version is created every six 27 | months. Using the `BiocManager` package helps users accurately install 28 | packages from the appropriate release. 29 | 30 | - `available()` shows all packages associated with a search pattern 31 | - `install()` installs and/or updates packages either CRAN or 32 | Bioconductor 33 | - `repositories()` shows all package repository URL endpoints 34 | - `valid()` checks and returns packages that are out-of-date or too new 35 | - `version()` returns the current Bioconductor version number 36 | 37 | ## Installation 38 | 39 | ``` r 40 | if (!requireNamespace("BiocManager", quietly = TRUE)) 41 | install.packages("BiocManager", repos = "https://cran.R-project.org") 42 | ``` 43 | 44 | ## Usage 45 | 46 | ### Checking Bioconductor version currently in use 47 | 48 | ``` r 49 | BiocManager::version() 50 | #> [1] '3.21' 51 | ``` 52 | 53 | ### Installing Bioconductor packages 54 | 55 | ``` r 56 | BiocManager::install(c("GenomicRanges", "SummarizedExperiment")) 57 | ``` 58 | 59 | ### Verifying a valid Bioconductor installation 60 | 61 | ``` r 62 | BiocManager::valid() 63 | #> [1] TRUE 64 | ``` 65 | 66 | ## More information 67 | 68 | Please see the ‘Get started’ document (package vignette) for more 69 | detailed information such as changing Bioconductor version, offline use, 70 | and other advanced usage. 71 | 72 | ## Getting help 73 | 74 | To report apparent bugs, create a minimal and reproducible example on 75 | [GitHub](https://github.com/Bioconductor/BiocManager/issues). 76 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | 3 | * local Ubuntu 24.04 (linux): R 4.4.2 patched, R 4.5.0 patched, R devel (r88148) 4 | * win-builder.r-project.org (windows): R 4.4.3, R 4.5.0, R devel (r88278) 5 | 6 | ## R CMD check results 7 | 8 | 0 errors | 0 warnings | 1 note 9 | 10 | * checking package dependencies ... NOTE 11 | Packages suggested but not available for checking: 12 | 'BiocVersion', 'BiocStyle' 13 | 14 | `BiocVersion` and `BiocStyle` are only available in Bioconductor. 15 | -------------------------------------------------------------------------------- /man/BiocManager-package.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/BiocManager-package.R 3 | \docType{package} 4 | \name{BiocManager-package} 5 | \alias{BiocManager-package} 6 | \alias{R_BIOC_VERSION} 7 | \alias{BiocManager} 8 | \title{Install or update Bioconductor, CRAN, or GitHub packages} 9 | \description{ 10 | This package provides tools for managing \emph{Bioconductor} and other 11 | packages in a manner consistent with \emph{Bioconductor}'s package 12 | versioning and release system. 13 | } 14 | \details{ 15 | Main functions are as follows; additional help is available for 16 | each function, e.g., \code{?BiocManager::version}. 17 | \itemize{ 18 | \item \code{BiocManager::install()}: Install or update packages from 19 | \emph{Bioconductor}, CRAN, and GitHub. 20 | \item \code{BiocManager::version()}: Report the version of \emph{Bioconductor} in 21 | use. 22 | \item \code{BiocManager::available()}: Return a \code{character()} vector of 23 | package names available (at \code{BiocManager::repositories()}) for 24 | installation. 25 | \item \code{BiocManager::valid()}: Determine whether installed packages are 26 | from the same version of \emph{Bioconductor}. 27 | \item \code{BiocManager::repositories()}: \emph{Bioconductor} and other 28 | repository URLs to discover packages for installation. 29 | } 30 | 31 | The version of \emph{Bioconductor} in use is determined by the installed 32 | version of a second package, BiocVersion. BiocVersion is installed 33 | automatically during first use of \code{BiocManager::install()}. If 34 | BiocVersion has not yet been installed, the version is determined 35 | by code in base R. 36 | 37 | Options influencing package behavior (see \code{?options}, \code{?getOption}) 38 | include: 39 | \itemize{ 40 | \item \code{"repos"}, \code{"BiocManager.check_repositories"}: URLs of additional 41 | repositories for use by \code{BiocManger::install()}. See \code{?repositories}. 42 | \item \code{"pkgType"}: The default type of packages to be downloaded and 43 | installed; see \code{?install.packages}. 44 | \item \code{"timeout"}: The maximum time allowed for download of a single 45 | package, in seconds. \emph{BiocManager} increases this to 300 seconds 46 | to accommodate download of large BSgenome and other packages. 47 | } 48 | 49 | System environment variables influencing package behavior include: 50 | \itemize{ 51 | \item \env{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} advanced 52 | configuration to avoid \emph{Bioconductor} version checks. See 53 | \code{?install}. 54 | \item \env{BIOCONDUCTOR_CONFIG_FILE} for offline use of BiocManager 55 | versioning functionality. See \code{?install}. 56 | \item \env{BIOCONDUCTOR_USE_CONTAINER_REPOSITORY} opt out of binary package 57 | installations. See \code{?containerRepository}. 58 | \item \env{BIOCMANAGER_CHECK_REPOSITORIES} silence messages regarding 59 | non-standard CRAN or Bioconductor repositories. See \code{?repositories}. 60 | \item \env{BIOCMANAGER_SITE_REPOSITORY} configure a more permanent 61 | \code{site_repository} input to \code{repositories()}. See \code{?repositories}. 62 | \item \env{R_BIOC_VERSION} use a specific, possibly unsupported, 63 | version of Bioconductor. \code{install()}, \code{version()}, \code{available()}, 64 | \code{valid()}, and \code{repositories()} all use the version \emph{without} 65 | checking that it is consistent with the version of \emph{R} in use. 66 | } 67 | } 68 | \examples{ 69 | R.version.string 70 | packageVersion("BiocManager") 71 | if (requireNamespace("BiocVersion", quietly = TRUE)) 72 | packageVersion("BiocVersion") 73 | BiocManager::version() 74 | } 75 | \seealso{ 76 | Useful links: 77 | \itemize{ 78 | \item \url{https://bioconductor.github.io/BiocManager/} 79 | \item Report bugs at \url{https://github.com/Bioconductor/BiocManager/issues} 80 | } 81 | 82 | } 83 | \author{ 84 | \strong{Maintainer}: Marcel Ramos \email{marcel.ramos@sph.cuny.edu} (\href{https://orcid.org/0000-0002-3242-0582}{ORCID}) 85 | 86 | Authors: 87 | \itemize{ 88 | \item Martin Morgan \email{martin.morgan@roswellpark.org} (\href{https://orcid.org/0000-0002-5874-8148}{ORCID}) 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /man/available.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/available.R 3 | \name{available} 4 | \alias{available} 5 | \title{Discover packages available for installation.} 6 | \usage{ 7 | available(pattern = "", include_installed = TRUE) 8 | } 9 | \arguments{ 10 | \item{pattern}{character(1) pattern to filter (via 11 | \code{grep(pattern=...)}) available packages; the filter is not case 12 | sensitive.} 13 | 14 | \item{include_installed}{logical(1) When \code{TRUE}, include installed 15 | packages in list of available packages; when \code{FALSE}, exclude 16 | installed packages.} 17 | } 18 | \value{ 19 | \code{character()} vector of package names available for 20 | installation. 21 | } 22 | \description{ 23 | The function lists all packages available from \code{repositories()} when 24 | no pattern is provided. This usually includes CRAN and Bioconductor 25 | packages. The function can also be used to check for package name 26 | availability. Common use cases include annotation package lookups by 27 | organism short name (e.g., "hsapiens"). 28 | } 29 | \examples{ 30 | if (interactive()) { 31 | avail <- BiocManager::available() 32 | length(avail) 33 | 34 | BiocManager::available("bs.*hsapiens") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /man/figures/BiocManager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/BiocManager/793c54101632062000ddd2e7d5b3aa13ae592c0d/man/figures/BiocManager.png -------------------------------------------------------------------------------- /man/install.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/install.R 3 | \name{install} 4 | \alias{install} 5 | \alias{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} 6 | \title{Install or update Bioconductor, CRAN, and GitHub packages} 7 | \usage{ 8 | install( 9 | pkgs = character(), 10 | ..., 11 | site_repository = character(), 12 | update = TRUE, 13 | ask = TRUE, 14 | checkBuilt = FALSE, 15 | force = FALSE, 16 | version = BiocManager::version() 17 | ) 18 | } 19 | \arguments{ 20 | \item{pkgs}{\code{character()} vector of package names to install or 21 | update. A missing value updates installed packages according 22 | to \verb{update =} and \verb{ask =}. Package names containing a '/' are 23 | treated as GitHub repositories and installed using 24 | \code{remotes::install_github()}.} 25 | 26 | \item{...}{Additional arguments used by \code{install.packages()}.} 27 | 28 | \item{site_repository}{(Optional) \code{character(1)} vector 29 | representing an additional repository in which to look for 30 | packages to install. This repository will be prepended to the 31 | default repositories (which you can see with 32 | \code{BiocManager::\link{repositories}()}).} 33 | 34 | \item{update}{\code{logical(1)}. When \code{FALSE}, \code{BiocManager::install()} 35 | does not attempt to update old packages. When \code{TRUE}, update 36 | old packages according to \code{ask}.} 37 | 38 | \item{ask}{\code{logical(1)} indicating whether to prompt user before 39 | installed packages are updated. If TRUE, user can choose 40 | whether to update all outdated packages without further 41 | prompting, to pick packages to update, or to cancel updating 42 | (in a non-interactive session, no packages will be updated 43 | unless \code{ask = FALSE}).} 44 | 45 | \item{checkBuilt}{\code{logical(1)}. If \code{TRUE} a package built under an 46 | earlier major.minor version of R (e.g., 3.4) is considered to 47 | be old.} 48 | 49 | \item{force}{\code{logical(1)}. If \code{TRUE} re-download a package that is 50 | currently up-to-date.} 51 | 52 | \item{version}{\code{character(1)} \emph{Bioconductor} version to install, 53 | e.g., \code{version = "3.8"}. The special symbol \code{version = "devel"} 54 | installs the current 'development' version.} 55 | } 56 | \value{ 57 | \code{BiocManager::install()} returns the \code{pkgs} argument, invisibly. 58 | } 59 | \description{ 60 | The \code{BiocManager::install()} function installs or 61 | updates \emph{Bioconductor} and CRAN packages in a \emph{Bioconductor} 62 | release. Upgrading to a new \emph{Bioconductor} release may require 63 | additional steps; see \url{https://bioconductor.org/install}. 64 | } 65 | \details{ 66 | Installation of \emph{Bioconductor} and CRAN packages use R's standard 67 | functions for library management -- \code{install.packages()}, 68 | \code{available.packages()}, \code{update.packages()}. Installation of GitHub 69 | packages uses the \code{remotes::install_github()}. 70 | 71 | When installing CRAN or \emph{Bioconductor} packages, typical arguments 72 | include: \code{lib.loc}, passed to \code{\link{old.packages}()} and used to 73 | determine the library location of installed packages to be updated; 74 | and \code{lib}, passed to \code{\link{install.packages}{}} to determine the 75 | library location where \code{pkgs} are to be installed. 76 | 77 | When installing GitHub packages, \code{...} is passed to the 78 | \pkg{remotes} package functions \code{\link[remotes]{install_github}()} 79 | and \code{remotes:::install()}. A typical use is to build vignettes, via 80 | \verb{dependencies=TRUE, build_vignettes=TRUE}. 81 | 82 | See \code{?repositories} for additional detail on customizing where 83 | BiocManager searches for package installation. 84 | 85 | \env{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} is an environment 86 | variable or global \code{options()} which, when set to \code{FALSE}, allows 87 | organizations and its users to use offline repositories with BiocManager 88 | while enforcing appropriate version checks between \emph{Bioconductor} and R. 89 | Setting \env{BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS} to \code{FALSE} can speed 90 | package loading when internet access is slow or non-existent, but may 91 | result in out-of-date information regarding the current release and 92 | development versions of \emph{Bioconductor}. In addition, offline 93 | organizations and its users should set the \env{BIOCONDUCTOR_CONFIG_FILE} 94 | environment variable or option to a \code{.yaml} file similar to 95 | \url{https://bioconductor.org/config.yaml} for full offline use and 96 | version validation. 97 | } 98 | \examples{ 99 | 100 | \dontrun{ 101 | ## update previously installed packages 102 | BiocManager::install() 103 | 104 | ## install Bioconductor packages, and prompt to update all 105 | ## installed packages 106 | BiocManager::install(c("GenomicRanges", "edgeR")) 107 | 108 | ## install a CRAN and Bioconductor packages: 109 | BiocManager::install(c("survival", "SummarizedExperiment")) 110 | 111 | ## install a package from source: 112 | BiocManager::install("IRanges", type="source") 113 | } 114 | 115 | } 116 | \seealso{ 117 | \code{BiocManager::\link{repositories}()} returns the \emph{Bioconductor} and 118 | CRAN repositories used by \code{install()}. 119 | 120 | \code{\link{install.packages}()} installs the packages themselves (used by 121 | \code{BiocManager::install} internally). 122 | 123 | \code{\link{update.packages}()} updates all installed packages (used by 124 | \code{BiocManager::install} internally). 125 | 126 | \code{\link{chooseBioCmirror}()} allows choice of a mirror from all 127 | public \emph{Bioconductor} mirrors. 128 | 129 | \code{\link{chooseCRANmirror}()} allows choice of a mirror from all 130 | public CRAN mirrors. 131 | } 132 | \keyword{environment} 133 | -------------------------------------------------------------------------------- /man/repositories.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/repositories.R 3 | \name{repositories} 4 | \alias{repositories} 5 | \alias{BiocManager.check_repositories} 6 | \alias{containerRepository} 7 | \alias{BINARY_BASE_URL} 8 | \title{Display current Bioconductor and CRAN repositories.} 9 | \usage{ 10 | repositories( 11 | site_repository = character(), 12 | version = BiocManager::version(), 13 | ..., 14 | type = "both" 15 | ) 16 | 17 | containerRepository(version = BiocManager::version(), type = "binary") 18 | } 19 | \arguments{ 20 | \item{site_repository}{(Optional) \code{character(1)} representing an 21 | additional repository (e.g., a URL to an organization's 22 | internally maintained repository) in which to look for packages 23 | to install. This repository will be prepended to the default 24 | repositories returned by the function.} 25 | 26 | \item{version}{(Optional) \code{character(1)} or \code{package_version} 27 | indicating the \emph{Bioconductor} version (e.g., "3.8") for which 28 | repositories are required.} 29 | 30 | \item{...}{Additional parameters passed to lower level functions, not 31 | used.} 32 | 33 | \item{type}{(Optional) \code{character(1)} indicating the type of package 34 | repository to retrieve (default: "both"). Setting \code{type} to "source" will 35 | disable any Bioconductor binary packages specifically built for the 36 | containers.} 37 | } 38 | \value{ 39 | \code{repositories()}: named \code{character()} of repositories. 40 | 41 | \code{containerRepository()}: character(1) location of binary repository, 42 | if available, or character(0) if not. 43 | } 44 | \description{ 45 | \code{repositories()} reports the URLs from which to 46 | install \emph{Bioconductor} and CRAN packages. It is used by 47 | \code{BiocManager::install()} and other functions. 48 | 49 | \code{containerRepository()} reports the location of the repository 50 | of binary packages for fast installation within containerized versions 51 | of Bioconductor, if available. 52 | } 53 | \details{ 54 | \code{repositories()} returns the appropriate software package 55 | repositories for your version of \emph{Bioconductor}. 56 | 57 | \emph{Bioconductor} has a 'release' and a 'devel' semi-annual release 58 | cycle. Packages within a release have been tested against each 59 | other and the current version of packages on CRAN. \emph{Bioconductor} 60 | best practice is to use packages from the same release, and from 61 | the appropriate CRAN repository. 62 | 63 | To install binary packages on containerized versions of Bioconductor, 64 | a default binary package location URL is set as a package constant, 65 | see \code{BiocManager:::BINARY_BASE_URL}. Binary package installations 66 | are enabled by default for Bioconductor Docker containers. Anyone 67 | wishing to opt out of the binary package installation can set either the 68 | variable or the option, \env{BIOCONDUCTOR_USE_CONTAINER_REPOSITORY}, to 69 | \code{FALSE}. Note that the availability of Bioconductor package binaries is 70 | experimental and binary installations are intended to be used with 71 | \code{bioconductor/bioconductor_docker} images where such installations 72 | correspond to specific versions of Linux / Ubuntu. 73 | 74 | If alternative default repositories are known to provide appropriate 75 | versions of CRAN or \emph{Bioconductor} packages, the message may be silenced 76 | by setting either the option or the variable to \code{FALSE}, i.e., 77 | \code{options(BiocManager.check_repositories = FALSE)} or 78 | \env{BIOCMANAGER_CHECK_REPOSITORIES=FALSE}. Alternative default 79 | repositories are not guaranteed to work without issues related to 80 | incompatible package installations and are used at the user's own risk. 81 | 82 | The intended use of \verb{site_repository =} is to enable installation of 83 | packages not available in the default repositories, e.g., packages 84 | internal to an organization and not yet publicly available. A 85 | secondary use might provide alternative versions (e.g., compiled 86 | binaries) of packages available in the default repositories. Note 87 | that \emph{R}'s standard rules of package selection apply, so the most 88 | recent version of candidate packages is selected independent of the 89 | location of the repository in the vector returned by \code{repositories()}. 90 | To set a more permenanent \code{site_repository}, one can use either the 91 | \env{BIOCMANAGER_SITE_REPOSITORY} environment variable or the 92 | \code{options(BiocManager.site_repository = ...)} option. 93 | 94 | For greater flexiblity in installing packages while still adhering 95 | as much as possible to \emph{Bioconductor} best practices, use 96 | \code{repositories()} as a basis for constructing the \verb{repos =} argument 97 | to \code{install.packages()} and related functions. 98 | 99 | The unexported URL to the base repository is available with 100 | \code{BiocManager:::BINARY_BASE_URL}. 101 | 102 | \env{BIOCONDUCTOR_USE_CONTAINER_REPOSITORY} is an environment 103 | variable or global \code{options()} which, when set to \code{FALSE}, avoids 104 | the fast installation of binary packages within containerized 105 | versions of Bioconductor. 106 | } 107 | \examples{ 108 | BiocManager::repositories() 109 | \dontrun{ 110 | BiocManager::repositories(version="3.8") 111 | } 112 | 113 | containerRepository() # character(0) if not within a Bioconductor container 114 | 115 | } 116 | \seealso{ 117 | \code{BiocManager::\link{install}()} Installs or updates Bioconductor, 118 | CRAN, and GitHub packages. 119 | 120 | \code{\link{chooseBioCmirror}()} choose an alternative Bioconductor 121 | mirror; not usually necessary. 122 | 123 | \code{\link{chooseCRANmirror}()} choose an alternative CRAN mirror; not 124 | usually necessary. 125 | 126 | \code{\link{setRepositories}()} Select additional repositories for 127 | searching. 128 | } 129 | \keyword{environment} 130 | -------------------------------------------------------------------------------- /man/valid.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/valid.R 3 | \name{valid} 4 | \alias{valid} 5 | \alias{print.biocValid} 6 | \title{Validate installed package versions against correct versions.} 7 | \usage{ 8 | valid( 9 | pkgs = installed.packages(lib.loc, priority = priority), 10 | lib.loc = NULL, 11 | priority = "NA", 12 | type = getOption("pkgType"), 13 | filters = NULL, 14 | ..., 15 | checkBuilt = FALSE, 16 | site_repository = character() 17 | ) 18 | 19 | \method{print}{biocValid}(x, ...) 20 | } 21 | \arguments{ 22 | \item{pkgs}{A character() vector of package names for checking, or 23 | a matrix as returned by \code{\link{installed.packages}()}`.} 24 | 25 | \item{lib.loc}{A character() vector of library location(s) of 26 | packages to be validated; see \code{\link{installed.packages}()}.} 27 | 28 | \item{priority}{character(1) Check validity of all, "base", or 29 | "recommended" packages; see \code{\link{installed.packages}()}.} 30 | 31 | \item{type}{character(1) The type of available package (e.g., 32 | binary, source) to check validity against; see 33 | \code{\link{available.packages}()}.} 34 | 35 | \item{filters}{character(1) Filter available packages to check 36 | validity against; see \code{\link{available.packages}()}.} 37 | 38 | \item{\dots}{Additional arguments, passed to 39 | \code{BiocManager::\link{install}()} when \code{fix=TRUE}.} 40 | 41 | \item{checkBuilt}{\code{logical(1)}. If \code{TRUE} a package built under an 42 | earlier major.minor version of R (e.g., 3.4) is considered to 43 | be old.} 44 | 45 | \item{site_repository}{\code{character(1)}. See \code{?install}.} 46 | 47 | \item{x}{A `biocValid` object returned by `BiocManager::valid()`.} 48 | } 49 | \value{ 50 | \code{biocValid} list object with elements \code{too_new} and 51 | \code{out_of_date} containing \code{data.frame}s with packages and their 52 | installed locations that are too new or out-of-date for the 53 | current version of \emph{Bioconductor}. When internet access 54 | is unavailable, an empty 'biocValid' list is returned. If all 55 | packages ('pkgs') are up to date, then TRUE is returned. 56 | 57 | `print()` is invoked for its side effect. 58 | } 59 | \description{ 60 | Check that installed packages are consistent (neither out-of-date 61 | nor too new) with the version of R and \emph{Bioconductor} in use. 62 | } 63 | \details{ 64 | This function compares the version of installed packages 65 | to the version of packages associated with the version of \emph{R} 66 | and \emph{Bioconductor} currently in use. 67 | 68 | Packages are reported as 'out-of-date' if a more recent version 69 | is available at the repositories specified by 70 | \code{BiocManager::repositories()}. Usually, \code{BiocManager::install()} is 71 | sufficient to update packages to their most recent version. 72 | 73 | Packages are reported as 'too new' if the installed version is 74 | more recent than the most recent available in the 75 | \code{BiocManager::repositories()}. It is possible to down-grade by 76 | re-installing a too new package "PkgA" with 77 | \code{BiocManger::install("PkgA")}. It is important for the user to 78 | understand how their installation became too new, and to avoid 79 | this in the future. 80 | } 81 | \examples{ 82 | if (interactive()) { 83 | BiocManager::valid() 84 | } 85 | } 86 | \seealso{ 87 | \code{BiocManager::\link{install}()} to update installed 88 | packages. 89 | } 90 | \author{ 91 | Martin Morgan \email{martin.morgan@roswellpark.org} 92 | } 93 | \keyword{environment} 94 | -------------------------------------------------------------------------------- /man/version.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/version.R 3 | \name{version} 4 | \alias{version} 5 | \alias{print.version_sentinel} 6 | \title{Version of Bioconductor currently in use.} 7 | \usage{ 8 | version() 9 | 10 | \method{print}{version_sentinel}(x, ...) 11 | } 12 | \arguments{ 13 | \item{x}{An \code{unknown_version} instance used to represent the 14 | situation when the version of Bioconductor in use cannot be 15 | determined.} 16 | 17 | \item{...}{Additional arguments, ignored.} 18 | } 19 | \value{ 20 | A two-digit version, e.g., \code{3.8}, of class 21 | \code{package_version} describing the version of \emph{Bioconductor} in 22 | use. 23 | } 24 | \description{ 25 | \code{version()} reports the version of \emph{Bioconductor} appropropriate 26 | for this version of R, or the version of \emph{Bioconductor} requested 27 | by the user. 28 | } 29 | \details{ 30 | \code{version()} (and all functions requiring version information) fails 31 | when version cannot be validated e.g., because internet access is 32 | not available. 33 | 34 | The environment variable \code{R_BIOC_VERSION} can be used to specify a 35 | version that is not consistent with \emph{Bioconductor} release 36 | versioning. Use of this variable is strongly discouraged. 37 | } 38 | \examples{ 39 | BiocManager::version() 40 | 41 | } 42 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(BiocManager) 3 | 4 | test_check("BiocManager") 5 | -------------------------------------------------------------------------------- /tests/testthat/test_inet.R: -------------------------------------------------------------------------------- 1 | ## test_that("inet_readChar() fails on timeout", { 2 | ## ## readability 3 | ## mock <- testthat::with_mock 4 | ## envvar <- withr::with_envvar 5 | ## readMock <- function(...) stop("mock error") 6 | 7 | ## expect_false(getOption("BIOCMANAGER_CRANCHECK_BEHAVIOR")) 8 | ## expect_false(BiocManager:::.is_CRAN_check()) 9 | 10 | ## cat("BIOCMANAGER_CRANCHECK_BEHAVIOR: ", getOption("BIOCMANAGER_CRANCHECK_BEHAVIOR"), "\n") 11 | ## cat(paste(names(Sys.getenv()), collapse="\n"), "\n") 12 | ## if (!any(grepl("_CRAN_", names(Sys.getenv())))) 13 | ## ## expect error not under --as-cran 14 | ## expect_error(mock(readChar = readMock, available()), "mock error") 15 | 16 | ## ## under CRAN (--as-cran) expect to find environmental variable(s) 17 | ## ## "*_CRAN_*" and to generate message instead of error 18 | ## expect_message({ 19 | ## envvar( 20 | ## c(FAUX_CRAN_VAR = "any"), 21 | ## mock(readChar = readMock, available()) 22 | ## ) 23 | ## }, "mock error") 24 | 25 | ## }) 26 | -------------------------------------------------------------------------------- /tests/testthat/test_install.R: -------------------------------------------------------------------------------- 1 | context("install()") 2 | 3 | test_that("Arguments are validated", { 4 | expect_error( 5 | install("foo", "bar"), 6 | "all '...' arguments to 'install\\(\\)' must be named" 7 | ) 8 | expect_error(install(TRUE), "is.character\\(pkgs\\) is not TRUE") 9 | expect_error(install(ask="foo"), "is.logical\\(ask\\) is not TRUE") 10 | }) 11 | 12 | test_that("Helpers filter the right packages", { 13 | .install_filter_r_repos <- BiocManager:::.install_filter_r_repos 14 | .install_filter_github_repos <- BiocManager:::.install_filter_github_repos 15 | 16 | r <- "foo" 17 | http <- c("http://foo.bar/baz", "https://foo.bar/baz") 18 | github <- c("foo/bar", "foo/bar@baz") 19 | all <- c(r, http, github) 20 | 21 | expect_identical(c(r, http), .install_filter_r_repos(all)) 22 | expect_identical(github, .install_filter_github_repos(all)) 23 | }) 24 | 25 | test_that(".install_repos() works", { 26 | .skip_if_misconfigured() 27 | skip_if_offline() 28 | repos <- repositories() 29 | old_pkgs <- matrix( 30 | c("pkgB", "/home/user/dir"), 1, 2, 31 | dimnames=list("pkgB", c("Package", "LibPath"))) 32 | inst_pkgs <- matrix( 33 | c("pkgA", "/home/user/dir"), 1, 2, 34 | dimnames=list("pkgA", c("Package", "LibPath"))) 35 | expect_identical( 36 | character(0), 37 | .install_repos( 38 | character(), old_pkgs, inst_pkgs, repos = repos, force = FALSE 39 | ) 40 | ) 41 | }) 42 | 43 | test_that(".install_github() works", { 44 | .skip_if_misconfigured() 45 | skip_if_offline() 46 | repos <- repositories() 47 | expect_identical( 48 | character(0), 49 | .install_github(character(), repos = repos, update = FALSE, ask = TRUE) 50 | ) 51 | }) 52 | 53 | test_that("Versions are checked in install", { 54 | expect_error(install(version = "0.1")) 55 | expect_error(install(1:3)) 56 | expect_error(install(NA)) 57 | expect_error(install(c("BioStrings", "S4Vectors", NA))) 58 | expect_error(install(site_repository = c("string1", "string2"))) 59 | expect_error(install(TRUE)) 60 | expect_error(install(ask = "No")) 61 | expect_error(install(ask = c("No", "Yes", NA))) 62 | expect_error(install(version = c("3.7", "3.6"))) 63 | expect_error(install(version = character())) 64 | expect_error(install(version = "")) 65 | expect_error(install(version = "3.4.2")) 66 | }) 67 | 68 | test_that("pkgs are not re-downloaded when force=FALSE", { 69 | .filter <- BiocManager:::.install_filter_up_to_date 70 | 71 | old_pkgs <- matrix( 72 | c("pkgB", "/home/user/dir"), 1, 2, 73 | dimnames=list("pkgB", c("Package", "LibPath"))) 74 | inst_pkgs <- matrix( 75 | c("pkgA", "pkgB", "/home/user/dir", "/home/user/dir"), 2, 2, 76 | dimnames=list(c("pkgA", "pkgB"), c("Package", "LibPath"))) 77 | 78 | # installed and not old 79 | expect_warning(.filter("pkgA", inst_pkgs, old_pkgs, FALSE)) 80 | # installed and not old but force 81 | expect_identical(.filter("pkgA", inst_pkgs, old_pkgs, TRUE), "pkgA") 82 | 83 | # installed and old 84 | expect_identical(.filter("pkgB", inst_pkgs, old_pkgs, FALSE), "pkgB") 85 | expect_identical(.filter("pkgB", inst_pkgs, old_pkgs, TRUE), "pkgB") 86 | 87 | # not installed and no info on old 88 | expect_identical(.filter("pkgC", inst_pkgs, old_pkgs, FALSE), "pkgC") 89 | }) 90 | 91 | context("install(update = TRUE) filters un-updatable packages") 92 | 93 | test_that("masked packages are filtered", { 94 | .filter <- BiocManager:::.package_filter_masked 95 | 96 | pkgs0 <- matrix( 97 | character(), 0, 2, 98 | dimnames=list(NULL, c("Package", "LibPath"))) 99 | 100 | expect_identical(pkgs0, .filter(pkgs0)) 101 | 102 | paths <- c(tempfile(), tempfile()) 103 | for (path in paths) dir.create(path) 104 | oLibPaths <- .libPaths() 105 | on.exit(.libPaths(oLibPaths)) 106 | .libPaths(paths) 107 | 108 | pkgs <- matrix( 109 | c("Foo", "Bar", "Baz", "Bim", paths, paths), 4, 2, 110 | dimnames=list(c("Foo", "Bar", "Baz", "Bim"), c("Package", "LibPath"))) 111 | expect_identical(pkgs, .filter(pkgs)) 112 | expect_identical(pkgs[c(1, 3, 2),], .filter(pkgs[c(1, 3, 2),])) 113 | 114 | pkgs <- matrix( 115 | c("Foo", "Bar", "Foo", paths, paths[2]), 3, 2, 116 | dimnames=list(c("Foo", "Bar", "Foo"), c("Package", "LibPath"))) 117 | expect_identical(pkgs[1:2,], .filter(pkgs)) 118 | pkgs <- pkgs[3:1,] 119 | expect_identical(pkgs[2:3,], .filter(pkgs)) 120 | }) 121 | 122 | test_that("unwriteable packages are not considered", { 123 | .filter <- BiocManager:::.package_filter_unwriteable 124 | ## setup 125 | dir.create(p0 <- tempfile()) 126 | on.exit(unlink(p0, recursive=TRUE)) 127 | 128 | pkgs0 <- matrix( 129 | character(), 0, 2, 130 | dimnames=list(NULL, c("Package", "LibPath"))) 131 | 132 | pkgs <- pkgs0 133 | expect_identical(pkgs, .filter(pkgs, NULL)) 134 | expect_identical(pkgs, .filter(pkgs, character())) 135 | expect_identical(pkgs, .filter(pkgs, tempdir())) 136 | 137 | pkgs <- matrix(c("Foo", p0), 1, byrow=TRUE, 138 | dimnames=list("Foo", c("Package", "LibPath"))) 139 | expect_identical(pkgs, .filter(pkgs, NULL)) 140 | expect_identical(pkgs, .filter(pkgs, p0)) 141 | 142 | p1 <- tempfile() 143 | pkgs <- matrix(c("Foo", p1), 1, byrow=TRUE, 144 | dimnames=list("Foo", c("Package", "LibPath"))) 145 | expect_identical(pkgs[FALSE,, drop=FALSE], .filter(pkgs, NULL)) 146 | expect_identical(pkgs[FALSE,, drop=FALSE], .filter(pkgs, p1)) 147 | expect_identical(pkgs, .filter(pkgs, p0)) 148 | 149 | pkgs <- matrix( 150 | c("Foo", p0, "Bar", p1, "Baz", p0), 3, 2, byrow=TRUE, 151 | dimnames=list(c("Foo", "Bar", "Baz"), c("Package", "LibPath"))) 152 | expect_identical(pkgs[c(1, 3),], .filter(pkgs, NULL)) 153 | expect_identical(pkgs, .filter(pkgs, p0)) 154 | expect_identical(pkgs0, .filter(pkgs, p1)) 155 | 156 | expect_message(.filter(pkgs, NULL), "^Installation paths not writeable") 157 | 158 | if (.Platform$OS.type == "windows") 159 | ## how to create a read-only directory? 160 | return(TRUE) 161 | 162 | isDirRnW <- dir.create(p2 <- tempfile(), mode="0400") # read but not write 163 | skip_if_not(isDirRnW) 164 | pkgs <- matrix(c("Foo", p2), 1, byrow=TRUE, 165 | dimnames=list("Foo", c("Package", "LibPath"))) 166 | expect_identical(pkgs0, .filter(pkgs, NULL)) 167 | 168 | pkgs <- matrix( 169 | c("Foo", p0, "Bar", p2, "Baz", p0), 3, 2, byrow=TRUE, 170 | dimnames=list(c("Foo", "Bar", "Baz"), c("Package", "LibPath"))) 171 | expect_identical(pkgs[c(1, 3),], .filter(pkgs, NULL)) 172 | expect_identical(pkgs0, .filter(pkgs, p2)) 173 | 174 | Sys.chmod(p2, mode="0700") 175 | unlink(p2, recursive=TRUE) 176 | }) 177 | 178 | test_that("packages can be written", { 179 | skip("too idiosyncratic for standardized testing") 180 | 181 | lib <- system.file(package="BiocManager", "tests", "cases", 182 | "lib", "Biobase") 183 | dir.create(locked <- tempfile()) 184 | file.copy(lib, locked, recursive=TRUE) 185 | 186 | oLibPaths <- .libPaths() 187 | on.exit(.libPaths(oLibPaths)) 188 | .libPaths(c(locked, .libPaths())) 189 | 190 | Sys.chmod(locked, mode="0500") 191 | install() 192 | Sys.chmod(locked, mode="0700") 193 | }) 194 | 195 | context("install(version =, ask=...) works") 196 | 197 | test_that(".install_ask_up_or_down_grade() works non-interactively", { 198 | skip_if(interactive()) 199 | expect_equal( 200 | FALSE, 201 | .install_ask_up_or_down_grade("xx", npkgs = 1L, cmp = 1L, ask = TRUE) 202 | ) 203 | expect_equal( 204 | TRUE, 205 | .install_ask_up_or_down_grade("xx", npkgs = 1L, cmp = 1L, ask = FALSE) 206 | ) 207 | }) 208 | 209 | test_that("install() fails with different version (non-interactive)", { 210 | map <- BiocManager:::.version_map() 211 | incr <- 1L 212 | version <- 213 | package_version(paste(version()$major, version()$minor + incr, sep=".")) 214 | expect_error(install(version = version)) 215 | }) 216 | 217 | test_that("install() passes the force argument to .install", { 218 | .skip_if_misconfigured() 219 | skip_if_offline() 220 | expect_true( 221 | with_mock( 222 | `BiocManager:::.install` = function(...) { 223 | list(...)[['force']] 224 | }, 225 | `BiocManager:::.version_compare` = function(...) { 226 | 0L 227 | }, 228 | suppressMessages( 229 | install(force = TRUE, update = FALSE) 230 | ) 231 | ) 232 | ) 233 | expect_false( 234 | with_mock( 235 | `BiocManager:::.install` = function(...) { 236 | list(...)[['force']] 237 | }, 238 | `BiocManager:::.version_compare` = function(...) { 239 | 0L 240 | }, 241 | suppressMessages( 242 | install(force = FALSE, update = FALSE) 243 | ) 244 | ) 245 | ) 246 | expect_true( 247 | with_mock( 248 | `BiocManager:::.install` = function(...) { 249 | list(...)[['force']] 250 | }, 251 | `BiocManager:::.version_compare` = function(...) { 252 | 1L 253 | }, 254 | `BiocManager:::.install_n_invalid_pkgs` = function(...) { 255 | 0L 256 | }, 257 | `BiocManager:::.install_updated_version` = function(...) { 258 | pkgs <<- list(...)[['force']] 259 | }, 260 | suppressMessages( 261 | install(force = TRUE, update = FALSE, ask = FALSE) 262 | ) 263 | ) 264 | ) 265 | expect_false( 266 | with_mock( 267 | `BiocManager:::.install` = function(...) { 268 | list(...)[['force']] 269 | }, 270 | `BiocManager:::.version_compare` = function(...) { 271 | 1L 272 | }, 273 | `BiocManager:::.install_n_invalid_pkgs` = function(...) { 274 | 0L 275 | }, 276 | `BiocManager:::.install_updated_version` = function(...) { 277 | pkgs <<- list(...)[['force']] 278 | }, 279 | suppressMessages( 280 | install(force = FALSE, update = FALSE, ask = FALSE) 281 | ) 282 | ) 283 | ) 284 | expect_false( 285 | with_mock( 286 | `BiocManager:::.install` = function(...) { 287 | list(...)[['update']] 288 | }, 289 | `BiocManager:::.version_compare` = function(...) { 290 | 1L 291 | }, 292 | `BiocManager:::.install_n_invalid_pkgs` = function(...) { 293 | 0L 294 | }, 295 | `BiocManager:::.install_updated_version` = function(...) { 296 | pkgs <<- list(...)[['update']] 297 | }, 298 | suppressMessages( 299 | install(force = FALSE, update = FALSE, ask = FALSE) 300 | ) 301 | ) 302 | ) 303 | expect_false( 304 | with_mock( 305 | `BiocManager:::.install` = function(...) { 306 | list(...)[['ask']] 307 | }, 308 | `BiocManager:::.version_compare` = function(...) { 309 | 1L 310 | }, 311 | `BiocManager:::.install_n_invalid_pkgs` = function(...) { 312 | 0L 313 | }, 314 | `BiocManager:::.install_updated_version` = function(...) { 315 | pkgs <<- list(...)[['ask']] 316 | }, 317 | suppressMessages( 318 | install(force = FALSE, update = FALSE, ask = FALSE) 319 | ) 320 | ) 321 | ) 322 | expect_null( 323 | with_mock( 324 | `BiocManager:::.install` = function(...) { 325 | list(...)[['checkBuilt']] 326 | }, 327 | `BiocManager:::.version_compare` = function(...) { 328 | 1L 329 | }, 330 | `BiocManager:::.install_n_invalid_pkgs` = function(...) { 331 | 0L 332 | }, 333 | `BiocManager:::.install_updated_version` = function(...) { 334 | pkgs <<- list(...)[['checkBuilt']] 335 | }, 336 | suppressMessages( 337 | install( 338 | force = FALSE, checkBuilt = TRUE, 339 | update = FALSE, ask = FALSE 340 | ) 341 | ) 342 | ) 343 | ) 344 | }) 345 | 346 | test_that("install() without package names passes ... to install.packages", { 347 | .skip_if_misconfigured() 348 | object <- FALSE 349 | with_mock( 350 | available.packages = function(...) { 351 | cbind( 352 | Package = "BiocGenerics", Version = "0.33.0", 353 | LibPath = .libPaths()[1] 354 | ) 355 | }, 356 | old.packages = function(...) { 357 | ## claim that BiocGenerics is out-of-date 358 | cbind( 359 | Package = "BiocGenerics", Version = "0.32.0", 360 | LibPath = .libPaths()[1] 361 | ) 362 | }, 363 | install.packages = function(pkgs, ..., INSTALL_opts) { 364 | object <<- 365 | identical(pkgs, c(Package = "BiocGenerics")) && 366 | identical(INSTALL_opts, "--build") 367 | }, 368 | install(ask = FALSE, INSTALL_opts = "--build") 369 | ) 370 | expect_true(object) 371 | }) 372 | -------------------------------------------------------------------------------- /tests/testthat/test_repositories.R: -------------------------------------------------------------------------------- 1 | context("repositories()") 2 | 3 | test_that("repositories() returns all repos", { 4 | .skip_if_misconfigured() 5 | skip_if_offline() 6 | allOS <- c("BioCsoft", "CRAN", "BioCann", "BioCexp", "BioCworkflows") 7 | if (version() >= "3.12") 8 | allOS <- c(allOS, "BioCbooks") 9 | expect_true(all(allOS %in% names(repositories()))) 10 | }) 11 | 12 | test_that("repositories() does not return any NA repos", { 13 | .skip_if_misconfigured() 14 | skip_if_offline() 15 | expect_true(!anyNA(repositories())) 16 | }) 17 | 18 | test_that("repositories() returns BioCsoft in repositories vector", { 19 | .skip_if_misconfigured() 20 | skip_if_offline() 21 | expect_true("BioCsoft" %in% names(repositories())) 22 | }) 23 | 24 | test_that("'site_repository=' inserted correctly", { 25 | .skip_if_misconfigured() 26 | skip_if_offline() 27 | site_repository <- "file:///tmp" 28 | repos <- repositories(site_repository) 29 | expect_identical(c(site_repository = site_repository), repos[1]) 30 | }) 31 | 32 | test_that("site_repository is used when env var or option available", { 33 | .skip_if_misconfigured() 34 | expected_repository <- "https://example.com/bioc" 35 | withr::with_envvar( 36 | c(BIOCMANAGER_SITE_REPOSITORY = expected_repository), 37 | { 38 | actual_repository <- .repositories_site_repository() 39 | expect_equal(actual_repository, expected_repository) 40 | } 41 | ) 42 | withr::with_envvar( 43 | c(BIOCMANAGER_SITE_REPOSITORY = ""), 44 | { 45 | actual_repository <- .repositories_site_repository() 46 | expect_equal(actual_repository, character(0L)) 47 | } 48 | ) 49 | withr::with_envvar( 50 | c(BIOCMANAGER_SITE_REPOSITORY = NULL), 51 | { 52 | actual_repository <- .repositories_site_repository() 53 | expect_equal(actual_repository, character(0L)) 54 | } 55 | ) 56 | withr::with_options( 57 | list(BiocManager.site_repository = expected_repository), 58 | { 59 | actual_value <- .repositories_site_repository() 60 | expect_equal(actual_value, expected_repository) 61 | } 62 | ) 63 | withr::with_options( 64 | list(BiocManager.site_repository = ""), 65 | { 66 | actual_value <- .repositories_site_repository() 67 | expect_equal(actual_value, character(0L)) 68 | } 69 | ) 70 | withr::with_options( 71 | list(BiocManager.site_repository = NULL), 72 | { 73 | actual_value <- .repositories_site_repository() 74 | expect_equal(actual_value, character(0L)) 75 | } 76 | ) 77 | }) 78 | 79 | test_that("repositories() rejects invalid versions", { 80 | skip_if_offline() 81 | expect_error( 82 | repositories(version="2.0"), 83 | "Bioconductor version '2.0' requires R version '2.5'.*" 84 | ) 85 | ## other validations tested in test_version.R 86 | }) 87 | 88 | test_that("repositories(version = 'devel') works", { 89 | .skip_if_misconfigured() 90 | skip_if_offline() 91 | if (version() == .version_bioc("devel")) { 92 | expect_equal( 93 | repositories(version = .version_bioc("devel")), 94 | repositories(version = "devel") 95 | ) 96 | } 97 | }) 98 | 99 | test_that("repositories helper replaces correct URL", { 100 | .skip_if_misconfigured() 101 | default_repos <- c(CRAN = "https://cloud.r-project.org") 102 | 103 | ## https://github.com/Bioconductor/BiocManager/issues/17 104 | repos <- "http://cran.cnr.Berkeley.edu" 105 | withr::with_options( 106 | list(repos = repos), 107 | expect_equal(.repositories_base(), repos) 108 | ) 109 | 110 | ## works as advertised 111 | repos <- c(CRAN = "@CRAN@") 112 | withr::with_options( 113 | list(repos = repos), 114 | expect_equal(.repositories_base(), default_repos) 115 | ) 116 | 117 | ## DO NOT update CRAN repo 118 | repos <- c(CRAN = "https://packagemanager.posit.co/") 119 | withr::with_options( 120 | list(repos = repos), 121 | { 122 | expect_message(.repositories_base()) 123 | expect_equal(.repositories_base(), repos) 124 | expect_message(repositories(), "'getOption\\(\"repos\"\\)'") 125 | } 126 | ) 127 | 128 | ## ...unless BiocManager.check_repositories == TRUE 129 | withr::with_options( 130 | list(repos = repos, BiocManager.check_repositories = FALSE), 131 | expect_equal(.repositories_base(), repos) 132 | ) 133 | 134 | ## DO NOT update other repositories... 135 | withr::with_options( 136 | list(repos = c(BioCsoft = "foo.bar")), 137 | expect_message(.repositories_base()) 138 | ) 139 | 140 | ## ...unless BiocManager.check_repositories == FALSE 141 | repos <- c(BioCsoft = "foo.bar") 142 | # other renaming 143 | withr::with_options( 144 | list(repos = repos, BiocManager.check_repositories = FALSE), 145 | expect_equal(.repositories_base(), repos) 146 | ) 147 | 148 | ## edge cases? 149 | repos <- character() # no repositories 150 | withr::with_options( 151 | list(repos = repos), 152 | expect_equal(.repositories_base(), repos) 153 | ) 154 | 155 | repos <- "@CRAN@" # unnamed 156 | withr::with_options( 157 | list(repos = repos), 158 | expect_equal(.repositories_base(), unname(default_repos)) 159 | ) 160 | }) 161 | 162 | test_that("'.repositories_filter()' works", { 163 | .skip_if_misconfigured() 164 | skip_on_cran() 165 | skip_if_offline("bioconductor.org") 166 | repos0 <- BiocManager::repositories() 167 | expect_equal(.repositories_filter(repos0), repos0) 168 | repos <- c(repos0, "https://bioconductor.org") 169 | expect_equal(.repositories_filter(repos), repos0) 170 | }) 171 | 172 | test_that("'containerRepository' uses 'type' argument", { 173 | skip_if_offline() 174 | bin_url <- "https://bioconductor.org/packages/%s/container-binaries/%s" 175 | ver <- "3.14" 176 | bin_url <- sprintf(bin_url, ver, "bioconductor_docker") 177 | expected_url <- setNames(bin_url, "BioCcontainers") 178 | withr::with_envvar( 179 | c( 180 | "BIOCONDUCTOR_DOCKER_VERSION" = ver, 181 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = TRUE 182 | ), 183 | expect_identical( 184 | containerRepository(version = ver, type = "source"), 185 | character(0L) 186 | ) 187 | ) 188 | withr::with_envvar( 189 | c( 190 | "BIOCONDUCTOR_DOCKER_VERSION" = ver, 191 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = TRUE 192 | ), 193 | expect_identical( 194 | containerRepository(version = ver, type = "both"), 195 | expected_url 196 | ) 197 | ) 198 | withr::with_envvar( 199 | c( 200 | "BIOCONDUCTOR_DOCKER_VERSION" = ver, 201 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = TRUE 202 | ), 203 | expect_identical( 204 | containerRepository(version = ver, type = "binary"), 205 | expected_url 206 | ) 207 | ) 208 | }) 209 | 210 | test_that("'containerRepository' & '.repositories_bioc' works", { 211 | skip_if_offline() 212 | bin_url <- "https://bioconductor.org/packages/%s/container-binaries/%s" 213 | ver <- "3.14" 214 | bin_url <- sprintf(bin_url, ver, "bioconductor_docker") 215 | expected_url <- setNames(bin_url, "BioCcontainers") 216 | # When no BIOCONDUCTOR_DOCKER_VERSION is set, no 'BioCcontainers' repo 217 | withr::with_envvar( 218 | c( 219 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = TRUE, 220 | "BIOCONDUCTOR_DOCKER_VERSION" = "" 221 | ), 222 | expect_true( 223 | !"BioCcontainers" %in% names(.repositories_bioc(ver)) 224 | ) 225 | ) 226 | # When no BIOCONDUCTOR_DOCKER_VERSION is set, expect empty string 227 | withr::with_envvar( 228 | c( 229 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = TRUE, 230 | "BIOCONDUCTOR_DOCKER_VERSION" = "" 231 | ), 232 | expect_identical( 233 | containerRepository(version = ver), 234 | character(0L) 235 | ) 236 | ) 237 | # When BIOCONDUCTOR_DOCKER_VERSION is set and 238 | # BIOCONDUCTOR_USE_CONTAINER_REPOSITORY is true, expect binaries url 239 | withr::with_envvar( 240 | c( 241 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = TRUE, 242 | "BIOCONDUCTOR_DOCKER_VERSION" = ver 243 | ), 244 | expect_identical( 245 | containerRepository(version = ver), 246 | expected_url 247 | ) 248 | ) 249 | # When no BIOCONDUCTOR_DOCKER_VERSION is set, expect empty string 250 | withr::with_envvar( 251 | c( 252 | "BIOCONDUCTOR_USE_CONTAINER_REPOSITORY" = FALSE, 253 | "BIOCONDUCTOR_DOCKER_VERSION" = ver 254 | ), 255 | expect_identical( 256 | containerRepository(version = ver), 257 | character(0L) 258 | ) 259 | ) 260 | }) 261 | -------------------------------------------------------------------------------- /tests/testthat/test_valid.R: -------------------------------------------------------------------------------- 1 | context("Check for the valid function") 2 | 3 | test_that("valid returns an empty list without internet", { 4 | .skip_if_misconfigured() 5 | 6 | result <- with_mock( 7 | `BiocManager:::.repositories_filter` = function(...) { 8 | ..1[FALSE] 9 | }, BiocManager::valid() 10 | ) 11 | 12 | expect_true( 13 | is(result, "biocValid") 14 | ) 15 | 16 | expect_identical( 17 | lengths(result), 18 | c(out_of_date = 0L, too_new = 0L) 19 | ) 20 | }) 21 | 22 | test_that("out of date filtering of BiocVersion works", { 23 | expect_null( 24 | .valid_out_of_date_filter(NULL) 25 | ) 26 | out_data_names <- c( 27 | "Package", "LibPath", "Installed", "Built", "ReposVer", "Repository" 28 | ) 29 | valid_out <- matrix( 30 | data = c( 31 | "BiocVersion", "/unit/test/lib/path", "3.17.1", "4.3.0", 32 | "3.18.0", "https://bioconductor.org/packages/3.18/bioc/src/contrib" 33 | ), 34 | nrow = 1, byrow = TRUE, 35 | dimnames = list( 36 | "BiocVersion", 37 | out_data_names 38 | ) 39 | ) 40 | expect_identical( 41 | .valid_out_of_date_filter(valid_out), 42 | matrix( 43 | data = character(0), nrow = 0, 44 | ncol = length(out_data_names), 45 | dimnames = list(NULL, out_data_names) 46 | ) 47 | ) 48 | valid_out <- matrix( 49 | data = c( 50 | "BiocVersion", "/unit/test/lib/path", "3.17.1", "4.3.0", 51 | "3.18.0", "https://bioconductor.org/packages/3.18/bioc/src/contrib", 52 | "apackage", "/unit/test/lib/path", "3.17.1", "4.3.0", 53 | "3.18.0", "https://bioconductor.org/packages/3.18/bioc/src/contrib" 54 | ), 55 | nrow = 2, byrow = TRUE, 56 | dimnames = list( 57 | c("BiocVersion", "apackage"), 58 | out_data_names 59 | ) 60 | ) 61 | expect_identical( 62 | .valid_out_of_date_filter(valid_out), 63 | matrix( 64 | data = c( 65 | "apackage", "/unit/test/lib/path", "3.17.1", "4.3.0", "3.18.0", 66 | "https://bioconductor.org/packages/3.18/bioc/src/contrib" 67 | ), 68 | nrow = 1, byrow = TRUE, 69 | dimnames = list("apackage", out_data_names) 70 | ) 71 | ) 72 | }) 73 | -------------------------------------------------------------------------------- /tests/testthat/test_version.R: -------------------------------------------------------------------------------- 1 | context("version()") 2 | 3 | inst_pkgs <- installed.packages() 4 | 5 | test_that("version is package_version class", { 6 | expect_s3_class(version(), "package_version") 7 | expect_s3_class(version(), "numeric_version") 8 | }) 9 | 10 | test_that("version has two components", { 11 | .skip_if_BiocVersion_not_available() 12 | verNums <- strsplit(as.character(version()), "\\.")[[1L]] 13 | expect_identical(length(verNums), 2L) 14 | }) 15 | 16 | test_that(".version_validate() validates version", { 17 | skip_if_offline() 18 | 19 | .version_validate <- BiocManager:::.version_validate 20 | 21 | expect_error( 22 | .version_validate("2.0"), 23 | "Bioconductor version '2.0' requires R version '2.5'; .*" 24 | ) 25 | 26 | expect_error( 27 | .version_validate("1.2.3"), 28 | "version '1.2.3' must have two components, e.g., '3.7'" 29 | ) 30 | 31 | expect_error( 32 | .version_validate("100.1"), 33 | "unknown Bioconductor version '100.1'; .*" 34 | ) 35 | 36 | }) 37 | 38 | test_that(".version_recommend() recommends update", { 39 | skip_if_offline() 40 | expect_true(startsWith( 41 | .version_recommend("2.0"), 42 | "Bioconductor version '2.0' is out-of-date" 43 | )) 44 | }) 45 | 46 | test_that(".version_validity_online_check() works", { 47 | ## environment variable 48 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=NULL), { 49 | withr::with_envvar(c(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=NA), { 50 | expect_identical(.version_validity_online_check(), TRUE) 51 | }) 52 | 53 | withr::with_envvar(c(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=TRUE), { 54 | expect_identical(.version_validity_online_check(), TRUE) 55 | }) 56 | 57 | withr::with_envvar(c(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=FALSE), { 58 | suppressWarnings({ 59 | expect_identical(.version_validity_online_check(), FALSE) 60 | }) 61 | }) 62 | }) 63 | 64 | ## options 65 | withr::with_envvar(c(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=NA), { 66 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=NULL), { 67 | expect_identical(.version_validity_online_check(), TRUE) 68 | }) 69 | }) 70 | 71 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=TRUE), { 72 | expect_identical(.version_validity_online_check(), TRUE) 73 | 74 | ## prefer option to env 75 | withr::with_envvar(c(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=FALSE), { 76 | expect_identical(.version_validity_online_check(), TRUE) 77 | }) 78 | }) 79 | 80 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=FALSE), { 81 | expect_identical(.version_validity_online_check(), FALSE) 82 | 83 | ## prefer option to env 84 | withr::with_envvar(c(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=TRUE), { 85 | expect_identical(.version_validity_online_check(), FALSE) 86 | }) 87 | }) 88 | }) 89 | 90 | test_that(".version_validity('devel') works", { 91 | .skip_if_misconfigured() 92 | skip_if_offline() 93 | devel <- .version_bioc("devel") 94 | R_version <- getRversion()[,1:2] 95 | map <- .version_map() 96 | R_ok <- map$R[map$Bioc == devel] 97 | if (identical(version(), devel) || R_version %in% R_ok) { 98 | expect_true(.version_validity("devel")) 99 | } else { 100 | test <- paste0("Bioconductor version '", devel, "' requires R version") 101 | expect_true(startsWith(.version_validity("devel"), test)) 102 | } 103 | }) 104 | 105 | test_that(".version_validity(...) works", { 106 | .skip_if_misconfigured() 107 | skip_if_offline() 108 | 109 | .version_validity <- BiocManager:::.version_validity 110 | 111 | .get_R_ver = function(ver = "4.3.0") { 112 | rver <- package_version(ver) 113 | class(rver) <- c("R_system_version", class(rver)) 114 | rver 115 | } 116 | 117 | ## proper mock map should include all four BiocStatus fields 118 | .ver_map <- data.frame( 119 | Bioc = package_version(c("3.9", "4.0", "4.1", "4.1")), 120 | R = package_version(c("4.2", "4.3", "4.4", "4.5")), 121 | BiocStatus = c("out-of-date", "release", "devel", "future") 122 | ) 123 | 124 | expect_true( 125 | .version_validity("4.0", .ver_map, .get_R_ver()) 126 | ) 127 | 128 | expect_match( 129 | .version_validity("4.1", .ver_map, .get_R_ver()), 130 | "Bioconductor version '4.1'" 131 | ) 132 | 133 | ## installing with future R versions supported 134 | expect_true( 135 | .version_validity("4.1", .ver_map, .get_R_ver("4.5.0")) 136 | ) 137 | 138 | .par_map <- .ver_map[1:2, ] 139 | expect_match( 140 | .version_validity("4.1", .par_map, .get_R_ver()), 141 | "Bioconductor version map cannot be validated; is it misconfigured?" 142 | ) 143 | }) 144 | 145 | test_that(".version_bioc() works", { 146 | .skip_if_misconfigured() 147 | skip_if_offline() 148 | 149 | .ver_map <- data.frame( 150 | Bioc = package_version(c("4.0", "4.1", "4.1")), 151 | R = package_version(c("4.3", "4.4", "4.5")), 152 | BiocStatus = c("release", "devel", "future") 153 | ) 154 | 155 | ## map misconfiguration 156 | with_mock( 157 | `BiocManager:::.version_map` = function(...) { 158 | .ver_map 159 | }, 160 | expect_match( 161 | .version_bioc("release"), 162 | "Bioconductor version map cannot be validated; is it misconfigured?" 163 | ) 164 | ) 165 | 166 | .ver_map <- rbind.data.frame(c("3.9", "4.2", "out-of-date"), .ver_map) 167 | 168 | ## all good 169 | with_mock( 170 | `BiocManager:::.version_map` = function(...) { 171 | .ver_map 172 | }, 173 | expect_identical( 174 | .version_bioc("release"), package_version("4.0") 175 | ) 176 | ) 177 | 178 | ## type misspecified 179 | type_miss <- 180 | "Bioconductor version cannot be validated; is type input misspecified?.*" 181 | with_mock( 182 | `BiocManager:::.version_map` = function(...) { 183 | .ver_map 184 | }, 185 | expect_match( 186 | .version_bioc("foo"), 187 | type_miss 188 | ) 189 | ) 190 | }) 191 | 192 | test_that(".version_R() works", { 193 | .skip_if_misconfigured() 194 | skip_if_offline() 195 | 196 | .ver_map <- data.frame( 197 | Bioc = package_version(c("4.0", "4.1", "4.1")), 198 | R = package_version(c("4.3", "4.4", "4.5")), 199 | BiocStatus = c("release", "devel", "future") 200 | ) 201 | ## out-of-date is missing 202 | with_mock( 203 | `BiocManager:::.version_map` = function(...) { 204 | .ver_map 205 | }, 206 | expect_match( 207 | .version_R("release"), 208 | "Bioconductor version map cannot be validated; is it misconfigured?.*" 209 | ) 210 | ) 211 | .ver_map <- rbind.data.frame(c("3.9", "4.2", "out-of-date"), .ver_map) 212 | ## all good 213 | with_mock( 214 | `BiocManager:::.version_map` = function(...) { 215 | .ver_map 216 | }, 217 | expect_identical( 218 | .version_R("release"), package_version("4.3") 219 | ) 220 | ) 221 | ## type is misspecified 222 | with_mock( 223 | `BiocManager:::.version_map` = function(...) { 224 | .ver_map 225 | }, 226 | expect_match( 227 | .version_R("foo"), 228 | "Bioconductor version cannot be validated; is type input misspecified?.*" 229 | ) 230 | ) 231 | }) 232 | 233 | test_that(".version_validity() and BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS work", 234 | { 235 | skip_if_offline() 236 | .skip_if_BiocVersion_not_available() 237 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=FALSE), { 238 | expect_match( 239 | .version_validity("1.2"), 240 | "unknown Bioconductor version '1.2'; .*" 241 | ) 242 | }) 243 | }) 244 | 245 | test_that(".version_validate() and BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS work",{ 246 | skip_if_offline() 247 | .skip_if_BiocVersion_not_available() 248 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=FALSE), { 249 | expect_error( 250 | .version_validate("1.2"), 251 | "unknown Bioconductor version '1.2'; .*" 252 | ) 253 | }) 254 | }) 255 | 256 | 257 | test_that(".version_map() and BIOCONDUCTOR_CONFIG_FILE work", { 258 | config <- tempfile(fileext = ".yaml") 259 | file.create(config) 260 | expect_true( 261 | !length( 262 | .version_map_get_online_config(config) 263 | ) 264 | ) 265 | expect_true( 266 | is.character( 267 | .version_map_get_online_config(config) 268 | ) 269 | ) 270 | expect_warning( 271 | .version_map_get_online_config("./fake/address/path/file.yaml") 272 | ) 273 | expect_identical( 274 | .version_map_get_online(config), 275 | .VERSION_MAP_SENTINEL 276 | ) 277 | skip_if_offline() 278 | expect_true( 279 | is.data.frame( 280 | .version_map_get_online("https://bioconductor.org/config.yaml") 281 | ) 282 | ) 283 | }) 284 | 285 | test_that(".version_map_get() and BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS work",{ 286 | withr::with_options(list(BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS=FALSE), { 287 | value <- .version_map_get() 288 | if ("BiocVersion" %in% rownames(inst_pkgs)) 289 | expect_identical(packageVersion("BiocVersion")[, 1:2], value[1, 1]) 290 | else 291 | expect_identical(value, .VERSION_MAP_SENTINEL) 292 | }) 293 | }) 294 | 295 | test_that(".version_map_get() falls back to http", { 296 | .VERSION_MAP$WARN_NO_ONLINE_CONFIG <- TRUE 297 | ## better test ideas welcome... 298 | url <- "https://httpbin.org/status/404" 299 | msgs <- list() 300 | result <- withCallingHandlers({ 301 | .version_map_get(url) 302 | }, warning = function(w) { 303 | msgs <<- c(msgs, list(w)) 304 | invokeRestart("muffleWarning") 305 | }) 306 | ## did we generate warnings and eventually fail gracefully? 307 | expect_identical(length(msgs), 2L) 308 | expect_true(all(vapply(msgs, is, logical(1), "simpleWarning"))) 309 | msgs <- vapply(msgs, conditionMessage, character(1)) 310 | expect_identical(sum(grepl("https://httpbin.org", msgs)), 1L) 311 | expect_identical(sum(grepl("http://httpbin.org", msgs)), 1L) 312 | expect_identical(result, .VERSION_MAP_SENTINEL) 313 | }) 314 | 315 | test_that(".VERSION_MAP_SENTINEL class and colnames", { 316 | expect_true( 317 | is.data.frame(.VERSION_MAP_SENTINEL) 318 | ) 319 | ## check column names 320 | expect_identical( 321 | c("Bioc", "R", "BiocStatus"), 322 | names(.VERSION_MAP_SENTINEL) 323 | ) 324 | }) 325 | 326 | test_that("BiocVersion version matches with .version_map()", { 327 | .skip_if_misconfigured() 328 | skip_if_offline() 329 | 330 | if (!"BiocVersion" %in% rownames(installed.packages())) 331 | skip("BiocVersion not installed") 332 | 333 | R_version <- getRversion() 334 | bioc_version <- packageVersion("BiocVersion")[, 1:2] 335 | 336 | expect_version <- 337 | function(bioc_version, R_version) 338 | { 339 | map <- .version_map() 340 | map <- map[map$R == R_version[,1:2], ] 341 | failure_message <- paste0( 342 | "BiocVersion package version '", bioc_version, "' does not match ", 343 | "BiocManager::.version_map() '", paste(map$Bioc, collapse="', '"), 344 | "'. Check configuration." 345 | ) 346 | expect(bioc_version %in% map$Bioc, failure_message) 347 | } 348 | expect_version(bioc_version, R_version) 349 | }) 350 | 351 | test_that(".version_sentinel() works", { 352 | msg <- "this is a message" 353 | vs <- .version_sentinel(msg) 354 | expect_true(is.na(vs)) 355 | expect_true(inherits(vs, "version_sentinel")) 356 | expect_true(inherits(vs, "package_version")) 357 | out <- capture.output(vs) 358 | expect_identical( 359 | paste0("unknown version: ", msg), 360 | out 361 | ) 362 | }) 363 | 364 | test_that(".version_BiocVersion returns .version_sentinel output", { 365 | with_mock( 366 | `BiocManager:::.version_BiocVersion_installed` = function(...) { 367 | FALSE 368 | }, 369 | expect_identical( 370 | .version_BiocVersion(), 371 | .version_sentinel("BiocVersion is not installed") 372 | ) 373 | ) 374 | }) 375 | 376 | test_that(".version_map_get_offline() works", { 377 | with_mock( 378 | `BiocManager:::.version_BiocVersion` = function(...) { 379 | .version_sentinel("BiocVersion is not installed") 380 | }, 381 | expect_identical( 382 | .version_map_get_offline(), 383 | .VERSION_MAP_SENTINEL 384 | ) 385 | ) 386 | .skip_if_misconfigured() 387 | skip_if_offline() 388 | rver <- package_version("4.3") 389 | class(rver) <- c("R_system_version", class(rver)) 390 | with_mock( 391 | `BiocManager:::.version_BiocVersion` = function(...) { 392 | package_version("3.14") 393 | }, 394 | `BiocManager:::.version_R_version` = function(...) { 395 | rver <- package_version("4.3") 396 | class(rver) <- c("R_system_version", class(rver)) 397 | rver 398 | }, 399 | expect_identical( 400 | .version_map_get_offline(), 401 | rbind(.VERSION_MAP_SENTINEL, data.frame( 402 | Bioc = package_version('3.14'), R = rver, 403 | BiocStatus = factor(NA, levels = .VERSION_TAGS) 404 | )) 405 | ) 406 | ) 407 | }) 408 | 409 | test_that("version chooses best", { 410 | target_version <- structure( 411 | list(c(3L, 17L), class = c("package_version", "numeric_version")) 412 | ) 413 | with_mock( 414 | `BiocManager:::.version_BiocVersion` = function(...) { 415 | .version_sentinel("BiocVersion is not installed") 416 | }, 417 | `BiocManager:::.version_choose_best` = function(...) { 418 | target_version 419 | }, 420 | expect_identical( 421 | .version_choose_best(), 422 | target_version 423 | ) 424 | ) 425 | }) 426 | 427 | test_that(".version_force_version() works", { 428 | skip_if_offline() 429 | 430 | test_version <- "3.16" 431 | withr::with_envvar( 432 | list(R_BIOC_VERSION = ""), 433 | expect_false(identical(version(), package_version(test_version))) 434 | ) 435 | withr::with_envvar( 436 | list(R_BIOC_VERSION = ""), 437 | expect_true(is.na(.version_force_version())) 438 | ) 439 | withr::with_envvar( 440 | list(R_BIOC_VERSION = test_version), 441 | expect_identical( 442 | .version_force_version(), package_version(test_version) 443 | ) 444 | ) 445 | withr::with_envvar( 446 | list(R_BIOC_VERSION = test_version), 447 | expect_identical(version(), package_version(test_version)) 448 | ) 449 | withr::with_envvar( 450 | list(R_BIOC_VERSION = test_version), 451 | expect_identical( 452 | .version_validate(test_version), 453 | package_version(test_version) 454 | ) 455 | ) 456 | withr::with_envvar( 457 | list(R_BIOC_VERSION = test_version), 458 | expect_identical(grep(test_version, repositories()), 1:5) 459 | ) 460 | 461 | new_lib <- tempfile(); dir.create(new_lib) 462 | withr::local_libpaths(new_lib) 463 | expect_error(packageVersion("BiocVersion", lib.loc = .libPaths()[1])) 464 | ## do *not* install BiocVersion 465 | withr::with_envvar(list(R_BIOC_VERSION = test_version), install()) 466 | expect_error(packageVersion("BiocVersion", lib.loc = .libPaths()[1])) 467 | ## install BiocVersion for original version 468 | original_version <- version() 469 | install("BiocVersion", lib = .libPaths()[1]) 470 | vers <- packageVersion("BiocVersion", lib.loc = .libPaths()[1]) 471 | expect_identical( 472 | package_version(paste(vers$major, vers$minor, sep = ".")), 473 | original_version 474 | ) 475 | ## BiocVersion ignored with R_BIOC_VERSION 476 | withr::with_envvar( 477 | list(R_BIOC_VERSION = test_version), 478 | expect_identical(version(), package_version(test_version)) 479 | ) 480 | }) 481 | -------------------------------------------------------------------------------- /vignettes/BiocManager.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Installing and Managing _Bioconductor_ Packages" 3 | author: 4 | - name: Marcel Ramos 5 | affiliation: Roswell Park Comprehensive Cancer Center, Buffalo, NY 6 | - name: Martin Morgan 7 | affiliation: Roswell Park Comprehensive Cancer Center, Buffalo, NY 8 | output: 9 | BiocStyle::html_document: 10 | toc: true 11 | vignette: | 12 | %\VignetteIndexEntry{Installing and Managing Bioconductor Packages} 13 | %\VignetteEngine{knitr::rmarkdown} 14 | %\VignetteEncoding{UTF-8} 15 | --- 16 | 17 | ```{r setup, include=FALSE} 18 | knitr::opts_chunk$set(echo = TRUE, eval = interactive()) 19 | ``` 20 | 21 | # Introduction 22 | 23 | Use the [BiocManager][1] package to install and manage packages from the 24 | _[Bioconductor][2]_ project for the statistical analysis and comprehension of 25 | high-throughput genomic data. 26 | 27 | Current _Bioconductor_ packages are available on a 'release' version intended 28 | for every-day use, and a 'devel' version where new features are introduced. A 29 | new release version is created every six months. Using the [BiocManager][1] 30 | package helps users install packages from the same release. 31 | 32 | # Basic use 33 | 34 | ## Installing _R_ 35 | 36 | We recommend using the current 'release' version of _R_. [Follow 37 | instructions][6] for installing _R_. 38 | 39 | ## Installing _BiocManager_ 40 | 41 | Use standard _R_ installation procedures to install the 42 | [BiocManager][1] package. This command is required only once per _R_ 43 | installation. 44 | 45 | ```{r, eval = FALSE} 46 | install.packages("BiocManager", repos = "https://cloud.r-project.org") 47 | ``` 48 | 49 | ## Installing _Bioconductor_, _CRAN_, or GitHub packages 50 | 51 | Install _Bioconductor_ (or CRAN) packages with 52 | 53 | ```{r, eval = FALSE} 54 | BiocManager::install(c("GenomicRanges", "Organism.dplyr")) 55 | ``` 56 | 57 | Installed packages can be updated to their current version with 58 | 59 | ```{r, eval = FALSE} 60 | BiocManager::install() 61 | ``` 62 | 63 | ## Previous releases 64 | 65 | To install CRAN package versions consistent with previous releases of 66 | Bioconductor, use the [BiocArchive][BiocArchive] package. BiocArchive enables 67 | contemporary installations of CRAN packages with out-of-date _Bioconductor_ 68 | releases using [Posit Public Package Manager][P3M]. 69 | 70 | [BiocArchive]: https://github.com/Bioconductor/BiocArchive 71 | [P3M]: https://packagemanager.posit.co/ 72 | 73 | ## Version and validity of installations 74 | 75 | Use `version()` to discover the version of _Bioconductor_ currently in 76 | use. 77 | 78 | ```{r} 79 | BiocManager::version() 80 | ``` 81 | 82 | _Bioconductor_ packages work best when they are all from the same release. Use 83 | `valid()` to identify packages that are out-of-date or from unexpected 84 | versions. 85 | 86 | ```{r} 87 | BiocManager::valid() 88 | ``` 89 | 90 | `valid()` returns an object that can be queried for detailed 91 | information about invalid packages, as illustrated in the following 92 | screen capture 93 | 94 | ``` 95 | > v <- valid() 96 | Warning message: 97 | 6 packages out-of-date; 0 packages too new 98 | > names(v) 99 | [1] "out_of_date" "too_new" 100 | > head(v$out_of_date, 2) 101 | Package LibPath 102 | bit "bit" "/home/mtmorgan/R/x86_64-pc-linux-gnu-library/3.5-Bioc-3.8" 103 | ff "ff" "/home/mtmorgan/R/x86_64-pc-linux-gnu-library/3.5-Bioc-3.8" 104 | Installed Built ReposVer Repository 105 | bit "1.1-12" "3.5.0" "1.1-13" "https://cloud.r-project.org/src/contrib" 106 | ff "2.2-13" "3.5.0" "2.2-14" "https://cloud.r-project.org/src/contrib" 107 | > 108 | ``` 109 | 110 | ## Available packages 111 | 112 | Packages available for your version of _Bioconductor_ can be 113 | discovered with `available()`; the first argument can be used to 114 | filter package names based on a regular expression, e.g., 'BSgenome' 115 | package available for _Homo sapiens_ 116 | 117 | ```{r} 118 | avail <- BiocManager::available() 119 | length(avail) # all CRAN & Bioconductor packages 120 | BiocManager::available("BSgenome.Hsapiens") # BSgenome.Hsapiens.* packages 121 | ``` 122 | 123 | Questions about installing and managing _Bioconductor_ packages should 124 | be addressed to the [_Bioconductor_ support site][3]. 125 | 126 | ## Updating old packages 127 | 128 | The user can often get an update packages prompt similar to: 129 | 130 | ``` 131 | > BiocManager::install("AnVIL") 132 | Bioconductor version 3.18 (BiocManager 1.30.22), R 4.3.1 (2023-06-16) 133 | Old packages: 'AnnotationDbi', 'arrow', 'basilisk.utils', 'beachmat', 134 | 'BiocParallel', 'BiocSingular', 'biocthis', 'Biostrings', 'bluster', 135 | 'DelayedArray', 'downlit', 'edgeR', 'GenomeInfoDb', 'GenomicFeatures', 136 | 'IRanges', 'limma', 'pkgbuild', 'pkgload', 'processx', 'RcppSpdlog', 'rhdf5', 137 | 'rstudioapi', 'SingleR', 'testthat', 'usethis', 'xml2', 'KernSmooth', 138 | 'Matrix', 'mgcv' 139 | Update all/some/none? [a/s/n]: 140 | ``` 141 | 142 | A decision should be made regarding updating packages. In the following section 143 | we will detail the rationale, pros, and cons of updating packages. 144 | 145 | (An initial draft of this section was produced by ChatGPT on 28 August 2023) 146 | 147 | ### Rationale 148 | 149 | Package updates often include bug fixes, improvements in functionality, and 150 | optimizations. By updating, the user can ensure that they are benefiting from 151 | the latest enhancements and fixes in the packages they use. 152 | 153 | ### Pros of updating 154 | 155 | * **Bug Fixes**: Updating packages can resolve known issues and bugs present in 156 | older versions. This can lead to more accurate and reliable analyses. 157 | * **Performance**: Package updates might come with performance optimizations 158 | that can lead to faster execution of code and analyses. 159 | * **New Features**: Updated packages might introduce new features, functions, 160 | and capabilities that can enhance your workflow and analysis options. 161 | * **Compatibility**: Newer packages are often developed with compatibility in 162 | mind. Using outdated packages might lead to compatibility issues with other 163 | packages or R itself. 164 | * **Security**: In some cases, package updates address security 165 | vulnerabilities. Keeping packages up to date can help maintain the security of 166 | the computational environment. 167 | * **Documentation**: Newer versions of packages might come with updated 168 | documentation that reflects recent changes and improvements in package 169 | functionality. 170 | 171 | ### Cons of updating 172 | 173 | * **Code Breakage**: Updates can introduce changes in package behavior, 174 | function signatures, or syntax. This can potentially break existing code if it 175 | relies on the previous behavior. 176 | * **Version Conflicts**: Updates to one package might trigger dependencies on 177 | updated versions of other packages. This can lead to conflicts if those updated 178 | versions are not compatible with other parts of your workflow. 179 | * **Workflow Disruption**: When you update packages, you might need to retest 180 | and validate your analyses to ensure that the changes in package behavior don't 181 | affect your results. 182 | * **Learning Curve**: New features and changes introduced in updated packages 183 | might require you to invest time in understanding how to use them effectively. 184 | * **Temporary Instability**: Right after a major update, the new version might 185 | not be as stable as the previous one, leading to unexpected behavior. 186 | 187 | ### Balancing the Decision 188 | 189 | * Consider how critical the package is to your analysis. If a package is central 190 | to your workflow, updating might be more important. 191 | * Read the release notes of the package to understand what changes are 192 | introduced in the update. 193 | * Consider using a separate environment (e.g., Docker container) for testing 194 | updates before applying them to the main analysis environment. 195 | * Make sure to backup code and data before performing updates. 196 | * Check if there are any compatibility issues with other packages you are using. 197 | 198 | ## Archived CRAN packages 199 | 200 | In the event that a package is no longer available on CRAN, it may be 201 | desirable to install an archived package, especially if it is assumed that the 202 | package will return to an unarchived state at a later date. Users who wish to 203 | protect their systems from the consequences of these state changes can 204 | install archived packages by using the [CRANhaven][] repository. This repository 205 | contains archived versions of CRAN packages for up to five weeks or until 206 | they are unarchived on CRAN. To enable archived CRAN package installations, the 207 | user can run the following command: 208 | 209 | ```{r,eval=FALSE} 210 | options( 211 | repos = c( 212 | getOption("repos"), 213 | CRANhaven = "https://cranhaven.r-universe.dev" 214 | ) 215 | ) 216 | BiocManager::install('archivedPackage') 217 | ``` 218 | 219 | [CRANhaven]: https://www.cranhaven.org/ 220 | 221 | # Advanced use 222 | 223 | ## Changing version 224 | 225 | Use the `version=` argument to update all packages to a specific _Bioconductor_ 226 | version 227 | 228 | ```{r, eval = FALSE} 229 | BiocManager::install(version="3.7") 230 | ``` 231 | 232 | _Bioconductor_ versions are associated with specific _R_ versions, as 233 | summarized [here][5]. Attempting to install a version of 234 | _Bioconductor_ that is not supported by the version of _R_ in use 235 | leads to an error; using the most recent version of _Bioconductor_ may 236 | require installing a new version of _R_. 237 | 238 | ``` 239 | > BiocManager::install(version="3.9") 240 | Error: Bioconductor version '3.9' requires R version '3.6'; see 241 | https://bioconductor.org/install 242 | ``` 243 | 244 | A special version, `version="devel"`, allows use of _Bioconductor_ 245 | packages that are under development. 246 | 247 | ## Unsupported *R* / *Bioconductor* versions 248 | 249 | The main purpose of BiocManager is to ensure that users install the 250 | version of *Bioconductor* appropriate for their version of *R*. Use 251 | the environment variable `R_BIOC_VERSION` to install any version of 252 | *Bioconductor* on any version of *R*. Thus *R* version 4.3.0 and 253 | *Bioconductor* version 3.19 are not compatible... 254 | 255 | ``` 256 | > BiocManager::install(version = "3.19") 257 | Error: Bioconductor version '3.19' requires R version '4.4'; use 258 | `version = '3.18'` with R version 4.3; see 259 | https://bioconductor.org/install 260 | ``` 261 | 262 | ...but the version can be forced with 263 | 264 | ``` 265 | > Sys.setenv(R_BIOC_VERSION="3.19") 266 | > BiocManager::install(version = "3.19") 267 | ... 268 | Bioconductor version 3.19 (BiocManager 1.30.23), R 4.3.0 (2023-04-21) 269 | ``` 270 | 271 | **Note**. Compatibility of Bioconductor with a mismatched version of R 272 | is not guaranteed and support is not provided for such installations. 273 | 274 | ## Managing multiple versions {#multiple-versions} 275 | 276 | It is possible to have multiple versions of _Bioconductor_ installed on the 277 | same computer. A best practice is to [create an initial _R_ installation][6]. 278 | Then create and use a library for each version of _Bioconductor_. The library 279 | will contain all _Bioconductor_, CRAN, and other packages for that version of 280 | _Bioconductor_. We illustrate the process assuming use of _Bioconductor_ 281 | version 3.7, available using _R_ version 3.5 282 | 283 | Create a directory to contain the library (replace `USER_NAME` with your user 284 | name on Windows) 285 | 286 | - Linux: `~/R/3.5-Bioc-3.7` 287 | - macOS: `~/Library/R/3.5-Bioc-3.7/library` 288 | - Windows: `C:\Users\USER_NAME\Documents\R\3.5-Bioc-3.7` 289 | 290 | Set the environment variable `R_LIBS_USER` to this directory, and invoke _R_. 291 | Command line examples for Linux are 292 | 293 | - Linux: `R_LIBS_USER=~/R/3.5-Bioc-3.7 R` 294 | - macOS: `R_LIBS_USER=~/Library/R/3.5-Bioc-3.7/library R` 295 | - Windows: `cmd /C "set R_LIBS_USER=C:\Users\USER_NAME\Documents\R\3.5-Bioc-3.7 && R"` 296 | 297 | Once in _R_, confirm that the version-specific library path has been set 298 | 299 | ```{r, eval = FALSE} 300 | .libPaths() 301 | ``` 302 | 303 | On Linux and macOS, create a bash alias to save typing, e.g., 304 | 305 | - Linux: `alias Bioc3.7='R_LIBS_USER=~/R/3.5-Bioc-3.7 R'` 306 | - macOS: `alias Bioc3.7='R_LIBS_USER=~/Library/R/3.5-Bioc-3.7/library R'` 307 | 308 | Invoke these from the command line as `Bioc3.7`. 309 | 310 | On Windows, create a shortcut. Go to My Computer and navigate to a directory 311 | that is in your PATH. Then right-click and choose New->Shortcut. 312 | In the "type the location of the item" box, put: 313 | 314 | ``` 315 | cmd /C "set R_LIBS_USER=C:\Users\USER_NAME\Documents\R\3.5-Bioc-3.7 && R" 316 | ``` 317 | 318 | Click "Next". In the "Type a name for this shortcut" box, type `Bioc-3.7`. 319 | 320 | ### Using the same R version {#same-r-version} 321 | 322 | Note that managing multiple versions of R and Bioconductor is important even 323 | when the Bioconductor versions use the same R version. The Bioconductor 324 | libraries should be kept in _separate_ directories to avoid conflicts between 325 | packages. For example, Bioconductor versions 3.7 and 3.8 both use R version 3.5. 326 | To manage packages from these versions, create _two_ separate library 327 | directories. Using the same setup as shown above, the second library directory 328 | would be: 329 | 330 | - Linux: `~/R/3.5-Bioc-3.8` 331 | - macOS: `~/Library/R/3.5-Bioc-3.8/library` 332 | - Windows: `C:\Users\USER_NAME\Documents\R\3.5-Bioc-3.8` 333 | 334 | It is also convenient to set a separate alias or shortcut for this version: 335 | 336 | - Linux: `alias Bioc3.8='R_LIBS_USER=~/R/3.5-Bioc-3.8 R'` 337 | - macOS: `alias Bioc3.8='R_LIBS_USER=~/Library/R/3.5-Bioc-3.8/library R'` 338 | 339 | On Windows, create a shortcut. Go to My Computer and navigate to a directory 340 | that is in your PATH. Then right-click and choose New->Shortcut. 341 | In the "type the location of the item" box, put: 342 | 343 | - Windows: `cmd /C "set R_LIBS_USER=C:\Users\USER_NAME\Documents\R\3.5-Bioc-3.8 && R"` 344 | 345 | Now there are two sets of aliases or shortcuts, one for each version of 346 | Bioconductor. This strategy can be extended to any number of versions of 347 | Bioconductor as long as the corresponding R version is installed on the 348 | system. When working with separate R versions, the path to the `R` executable 349 | must be specified in the alias or shortcut. 350 | 351 | Keep in mind that mixing packages from different versions of Bioconductor 352 | can lead to unexpected behavior and errors. 353 | 354 | ## Offline use 355 | 356 | Offline use of _BiocManager_ is possible for organizations and users that would 357 | like to provide access to internal repositories of _Bioconductor_ packages 358 | while enforcing appropriate version checks between Bioconductor and R. 359 | For offline use, organizations and users require the following steps: 360 | 361 | 1. Use `rsync` to create local repositories of [CRAN][8] and 362 | [Bioconductor][7]. Tell _R_ about these repositories using (e.g., 363 | in a site-wide `.Rprofile`, see `?.Rprofile`). 364 | 365 | ```{r, eval = FALSE} 366 | options( 367 | repos = c(CRAN_mirror = "file:///path/to/CRAN-mirror"), 368 | BioC_mirror = "file:///path/to/Bioc-mirror" 369 | ) 370 | ``` 371 | 372 | Validate repository setting by reviewing the output of `repositories()`. 373 | 374 | 2. Create an environment variable or option, e.g., 375 | 376 | ```{r, eval = FALSE} 377 | options( 378 | BIOCONDUCTOR_ONLINE_VERSION_DIAGNOSIS = FALSE 379 | ) 380 | ``` 381 | 382 | 3. Use `install.packages()` to bootstrap the BiocManager installation. 383 | 384 | ```{r, eval = FALSE} 385 | install.package(c("BiocManager", "BiocVersion")) 386 | ``` 387 | 388 | BiocManager can then be used for subsequent installations, e.g., 389 | `BiocManager::install(c("ggplot2", "GenomicRanges"))`. 390 | 391 | ### Offline config.yaml 392 | 393 | _BiocManager_ also expects to reference an online configuration yaml 394 | file for _Bioconductor_ version validation at 395 | https://bioconductor.org/config.yaml. With offline use, users are 396 | expected to either host this file locally or provide their 397 | `config.yaml` version. The package allows either an environment 398 | variable or R-specific option to locate this file, e.g., 399 | 400 | ```{r, eval = FALSE} 401 | options( 402 | BIOCONDUCTOR_CONFIG_FILE = "file:///path/to/config.yaml" 403 | ) 404 | ``` 405 | 406 | # How it works 407 | 408 | BiocManager's job is to make sure that all packages are installed from 409 | the same _Bioconductor_ version, using compatible _R_ and _CRAN_ 410 | packages. However, _R_ has an annual release cycle, whereas 411 | _Bioconductor_ has a twice-yearly release cycle. Also, _Bioconductor_ 412 | has a 'devel' branch where new packages and features are introduced, 413 | and a 'release' branch where bug fixes and relative stability are 414 | important; _CRAN_ packages do not distinguish between devel and 415 | release branches. 416 | 417 | In the past, one would install a _Bioconductor_ package by evaluating 418 | the command `source("https://.../biocLite.R")` to read a file from the 419 | web. The file contained an installation script that was smart enough 420 | to figure out what version of _R_ and _Bioconductor_ were in use or 421 | appropriate for the person invoking the script. Sourcing an executable 422 | script from the web is an obvious security problem. In 2024, the script 423 | was removed and is no longer in use. 424 | 425 | Our solution is to use a CRAN package BiocManager, so that users 426 | install from pre-configured CRAN mirrors rather than typing in a URL 427 | and sourcing from the web. 428 | 429 | But how does a CRAN package know what version of _Bioconductor_ is in 430 | use? Can we use BiocManager? No, because we don't have enough control 431 | over the version of BiocManager available on CRAN, e.g., everyone using 432 | the same version of _R_ would get the same version of BiocManager and 433 | hence of _Bioconductor_. But there are two _Bioconductor_ versions per R 434 | version, so that does not work! 435 | 436 | BiocManager could write information to a cache on the user disk, but 437 | this is not a robust solution for a number of reasons. Is there any 438 | other way that _R_ could keep track of version information? Yes, by 439 | installing a _Bioconductor_ package (BiocVersion) whose sole purpose is 440 | to indicate the version of _Bioconductor_ in use. 441 | 442 | By default, BiocManager installs the BiocVersion package corresponding 443 | to the most recent released version of _Bioconductor_ for the version 444 | of _R_ in use. At the time this section was written, the most recent 445 | version of R is R-3.6.1, associated with _Bioconductor_ release 446 | version 3.9. Hence on first use of `BiocManager::install()` we see 447 | BiocVersion version 3.9.0 being installed. 448 | 449 | ``` 450 | > BiocManager::install() 451 | Bioconductor version 3.9 (BiocManager 1.30.4), R 3.6.1 Patched (2019-07-06 452 | r76792) 453 | Installing package(s) 'BiocVersion' 454 | trying URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/\ 455 | BiocVersion_3.9.0.tar.gz' 456 | ... 457 | ``` 458 | 459 | Requesting a specific version of _Bioconductor_ updates, if possible, 460 | the BiocVersion package. 461 | 462 | ``` 463 | > ## 3.10 is available for R-3.6 464 | > BiocManager::install(version="3.10") 465 | Upgrade 3 packages to Bioconductor version '3.10'? [y/n]: y 466 | Bioconductor version 3.10 (BiocManager 1.30.4), R 3.6.1 Patched (2019-07-06 467 | r76792) 468 | Installing package(s) 'BiocVersion' 469 | trying URL 'https://bioconductor.org/packages/3.10/bioc/src/contrib/\ 470 | BiocVersion_3.10.1.tar.gz' 471 | ... 472 | > ## back down again... 473 | > BiocManager::install(version="3.9") 474 | Downgrade 3 packages to Bioconductor version '3.9'? [y/n]: y 475 | Bioconductor version 3.9 (BiocManager 1.30.4), R 3.6.1 Patched (2019-07-06 476 | r76792) 477 | Installing package(s) 'BiocVersion' 478 | trying URL 'https://bioconductor.org/packages/3.9/bioc/src/contrib/\ 479 | BiocVersion_3.9.0.tar.gz' 480 | ... 481 | ``` 482 | 483 | Answering `n` to the prompt to up- or downgrade packages leaves the 484 | installation unchanged, since this would immediately create an 485 | inconsistent installation. 486 | 487 | # Troubleshooting 488 | 489 | ## Package not available 490 | 491 | (An initial draft of this section was produced by ChatGPT on 25 May 2023) 492 | 493 | A user failed to install the 'celldex' package on 25 May 2023. A 494 | transcript of the _R_ session is as follows: 495 | 496 | ``` 497 | > BiocManager::version() 498 | [1] '3.18' 499 | > BiocManager::install("celldex") 500 | Bioconductor version 3.18 (BiocManager 1.30.20), R 4.3.0 Patched (2023-05-01 501 | r84362) 502 | Installing package(s) 'celldex' 503 | Warning message: 504 | package 'celldex' is not available for Bioconductor version '3.18' 505 | 506 | A version of this package for your version of R might be available elsewhere, 507 | see the ideas at 508 | https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 509 | ``` 510 | 511 | The availability of specific packages within _Bioconductor_ can depend 512 | on various factors, including simple errors in entering the package 513 | name, the package's development status, maintenance, and compatibility 514 | with the latest version of _Bioconductor_, as well as the availability 515 | of CRAN packages that the _Bioconductor_ package depends on. 516 | 517 | Package Name: _R_ package names are case sensitive and must be spelt 518 | correctly, so using `BiocManager::install("Celldex")` (with a capital 519 | `C`) or `BiocManager::install("celdex")` (with only one `l`) would 520 | both fail to install `celldex`; _R_ will sometimes suggest the correct 521 | name. 522 | 523 | _CRAN_ Packages: `BiocManager::install()` tries to install packages 524 | from CRAN and from _Bioconductor_. Check that the package is not a CRAN 525 | package by trying to visit the CRAN 'landing page' 526 | 527 | - `https://cran.R-project.org/package=celldex` 528 | 529 | If this page is found, then the package is a CRAN package; see the 530 | [R-admin][9] manual section on troubleshooting CRAN package 531 | installations. 532 | 533 | Check also that the package is not a CRAN package that has been 534 | 'archived' and no longer available by trying to visit 535 | 536 | - `https://cran.R-project.org/src/contrib/Archive/celldex/` 537 | 538 | If this page exists but the 'landing page' does not, this means that 539 | the package has been removed from CRAN. While it is possible to 540 | install archived packages, usually the best course of action is to 541 | identify alternative packages to accomplish the task you are 542 | interested in. This is especially true if the 'Last modified' date of 543 | the most recent archived package is more than several months ago. 544 | 545 | Compatibility: A _Bioconductor_ package must be available for the 546 | specific version of _Bioconductor_ you are using. Try visiting the 547 | 'landing page' of the package for your version of _Bioconductor_, 548 | e.g., for _Bioconductor_ version 3.18 and package celldex 549 | 550 | - https://bioconductor.org/packages/3.18/celldex 551 | 552 | If this landing page does not exist, then the package is not available 553 | for your version of _Bioconductor_. 554 | 555 | Users may sometimes have an out-of-date version of _R_ or 556 | _Bioconductor_ installed; this may be intentional (e.g., to ensure 557 | reproducibility of existing analyses) or simply because _Bioconductor_ 558 | has not yet been updated. Try visiting the current release landing 559 | page 560 | 561 | - https://bioconductor.org/packages/release/celldex 562 | 563 | If the release landing page exists, and it is not important that you 564 | continue using the out-of-date version of _Bioconductor_, consider 565 | updating _R_ (if necessary) and _Bioconductor_ to the current release 566 | versions using instructions at the top of this document. 567 | 568 | Packages recently contributed to _Bioconductor_ are added to the 569 | 'devel' branch, whereas most users are configured to use the 'release' 570 | branch. Try visiting the 'devel' landing page 571 | 572 | - https://bioconductor.org/packages/devel/celldex 573 | 574 | If only the devel landing page exists, then consider updating your 575 | installation to use the development version of _Bioconductor_. Note 576 | that the development version is not as stable as the release version, 577 | so should not be used for time-critical or 'production' analysis. 578 | 579 | It may be that the package you are interested in has been removed from 580 | _Bioconductor_. Check this by visiting 581 | 582 | - https://bioconductor.org/about/removed-packages/ 583 | 584 | If the package has been removed, the best course of action is to 585 | identify alternative packages to accomplish the task you are 586 | interested in. 587 | 588 | Maintenance and Operating System Availability: A package may be 589 | included in the release or devel version of _Bioconductor_, but 590 | currently unavailable because it requires maintenance. This might be 591 | indicated by a red 'build' badge as in the image below (details of the 592 | build problem are available by clicking on the badge). The build error 593 | usually requires that the package maintainer correct an issue with 594 | their package; the maintainer and email address are listed on the 595 | package landing page. 596 | 597 | ```{r out.width = '100%', echo = FALSE, eval = TRUE} 598 | knitr::include_graphics("img/badges.png") 599 | ``` 600 | 601 | A small number of _Bioconductor_ packages are not available on all 602 | operating systems. An orange 'platforms' badge indicates this. Click 603 | on the badge to be taken to the 'Package Archives' section of the 604 | landing page; BGmix is not supported on Windows, and not available on 605 | 'Intel' macOS because of build-related errors. Consider using an 606 | alternative operating system if the package is essential to your work 607 | 608 | ```{r out.width = '100%', echo = FALSE, eval = TRUE} 609 | knitr::include_graphics("img/archives.png") 610 | ``` 611 | 612 | Packages with landing pages from older releases but not available for 613 | your operating system cannot be updated by the maintainer. If the 614 | package is available in the current release and for your operating 615 | system, consider updating to the current release of _Bioconductor_. 616 | 617 | ## Cannot load _BiocManager_ 618 | 619 | After updating _R_ (e.g., from _R_ version 3.5.x to _R_ version 3.6.x 620 | at the time of writing this) and trying to load `BiocManager`, _R_ 621 | replies 622 | 623 | ``` 624 | Error: .onLoad failed in loadNamespace() for 'BiocManager', details: 625 | call: NULL 626 | error: Bioconductor version '3.8' requires R version '3.5'; see 627 | https://bioconductor.org/install 628 | ``` 629 | 630 | This problem arises because `BiocManager` uses a second package, 631 | `BiocVersion`, to indicate the version of _Bioconductor_ in use. In 632 | the original installation, `BiocManager` had installed `BiocVersion` 633 | appropriate for _R_ version 3.5. With the update, the version of 634 | _Bioconductor_ indicated by `BiocVersion` is no longer valid -- you'll 635 | need to update `BiocVersion` and all _Bioconductor_ packages to the 636 | most recent version available for your new version of _R_. 637 | 638 | The recommended practice is to maintain a separate library for each 639 | _R_ and _Bioconductor_ version. So instead of installing packages into 640 | _R_'s system library (e.g., as 'administrator'), install only base _R_ 641 | into the system location. Then use aliases or other approaches to 642 | create _R_ / _Bioconductor_ version-specific installations. This is 643 | described in the section on [maintaining multiple 644 | versions](#multiple-versions) of _R_ and _Bioconductor_. 645 | 646 | Alternatively, one could update all _Bioconductor_ packages in the 647 | previous installation directory. The problem with this is that the 648 | previous version of _Bioconductor_ is removed, compromising the 649 | ability to reproduce earlier results. Update all _Bioconductor_ 650 | packages in the previous installation directory by removing _all_ 651 | versions of `BiocVersion` 652 | 653 | ``` 654 | remove.packages("BiocVersion") # repeat until all instances removed 655 | ``` 656 | 657 | Then install the updated `BiocVersion`, and update all _Bioconductor_ 658 | packages; answer 'yes' when you are asked to update a potentially 659 | large number of _Bioconductor_ packages. 660 | 661 | ```{r, eval = FALSE} 662 | BiocManager::install() 663 | ``` 664 | 665 | Confirm that the updated _Bioconductor_ is valid for your version of 666 | _R_ 667 | 668 | ```{r, eval = FALSE} 669 | BiocManager::valid() 670 | ``` 671 | 672 | ## Timeout during package download 673 | 674 | Large packages can take a long time to downloaded over poor internet 675 | connects. The BiocManager package sets the time limit to 300 seconds, 676 | using `options(timeout = 300)`. Only part of a package may download, 677 | e.g., only 15.1 of 79.4 MB in the example below 678 | 679 | ``` 680 | trying URL 'https://bioconductor.org/packages/3.12/data/annotation/src/contrib/org.Hs.eg.db_3.12.0.tar.gz' 681 | Content type 'application/x-gzip' length 83225518 bytes (79.4 MB) 682 | ========= 683 | downloaded 15.1 MB 684 | ``` 685 | 686 | or perhaps with a warning (often difficult to see in the output) 687 | 688 | ``` 689 | Error in download.file(url, destfile, method, mode = "wb", ...) : 690 | ... 691 | ...: Timeout of 300 seconds was reached 692 | ... 693 | ``` 694 | 695 | Try increasing the download timeout, e.g, `options(timeout = 600)`. 696 | 697 | ## Multiple `BiocVersion` installations 698 | 699 | One potential problem occurs when there are two or more `.libPaths()`, 700 | with more than one BiocVersion package installed. This might occur for 701 | instance if a 'system administrator' installed BiocVersion, and then a 702 | user installed their own version. In this circumstance, it seems 703 | appropriate to standardize the installation by repeatedly calling 704 | `remove.packages("BiocVersion")` until all versions are removed, and 705 | then installing the desired version. 706 | 707 | ## Errors determining _Bioconductor_ version 708 | 709 | An essential task for _BiocManager_ is to determine that the version 710 | of _Bioconductor_ is appropriate for the version of _R_. Several 711 | errors can occur when this task fails. 712 | 713 | - Bioconductor version cannot be determined; no internet connection? 714 | When the _Bioconductor_ version cannot be obtained from the version 715 | map hosted at https://bioconductor.org/config.yaml, this error will 716 | occur. It may be a result of poor internet connectivity or offline 717 | use. See the [offline config.yaml](#offline-config.yaml) section 718 | above. 719 | 720 | - Bioconductor version cannot be validated; no internet connection? 721 | Usually occurs when the map is unable to be downloaded possibly due 722 | to a missing `BIOCONDUCTOR_CONFIG_FILE`. For offline use, a copy of 723 | the configuration file should be downloaded and its address set to 724 | the environment variable or option. 725 | 726 | - Bioconductor version map cannot be validated; is it misconfigured? 727 | On _rare_ occasion, the version map hosted at 728 | https://bioconductor.org/config.yaml may be misconfigured. The check 729 | ensures that all the version name tags, i.e., out-of-date, release, 730 | devel, and future are in the map. 731 | 732 | - Bioconductor version cannot be validated; is type input 733 | mis-specified? The type input refers to the version name inputs, 734 | mainly release and devel. This error is chiefly due to internal 735 | logic and is not due to user error. Please open a [GitHub 736 | issue][10]. 737 | 738 | # Session information 739 | 740 | ```{r, eval = TRUE} 741 | sessionInfo() 742 | ``` 743 | 744 | [1]: https://cran.r-project.org/package=BiocManager 745 | [2]: https://bioconductor.org 746 | [3]: https://support.bioconductor.org 747 | [5]: https://bioconductor.org/about/release-announcements/ 748 | [6]: https://cran.R-project.org/ 749 | [7]: https://bioconductor.org/about/mirrors/mirror-how-to/ 750 | [8]: https://cran.r-project.org/mirror-howto.html 751 | [9]: https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages 752 | [10]: https://github.com/Bioconductor/BiocManager/issues 753 | -------------------------------------------------------------------------------- /vignettes/img/archives.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/BiocManager/793c54101632062000ddd2e7d5b3aa13ae592c0d/vignettes/img/archives.png -------------------------------------------------------------------------------- /vignettes/img/badges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/BiocManager/793c54101632062000ddd2e7d5b3aa13ae592c0d/vignettes/img/badges.png --------------------------------------------------------------------------------