Skip to content

Commit

Permalink
allow BioConductor packages to be detected
Browse files Browse the repository at this point in the history
This provides a second chance to install bioconductor packages that were
missed on the first pass by implementing the strategy in
<#365 (comment)>,
which is to prepend the package name with `bioc::` and re-run
`renv::install()`
  • Loading branch information
zkamvar committed Feb 14, 2023
1 parent cf34e05 commit e2e6603
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
8 changes: 8 additions & 0 deletions NEWS.md
Expand Up @@ -7,6 +7,14 @@
warning will be issued listing which episodes have missing timings.
(reported: @zkamvar, #395; fixed: @zkamvar, #396)

## BUG FIX

* `manage_deps()` will now attempt to recover errors from "missing" bioconductor
packages. Note that this is a provisional solution because it treats
BioConductor packages as an afterthought. The full fix for this should be
when {renv} bootstraps BioConductor repositories (reported: @zkamvar, #365 and
https://github.com/rstudio/renv/issues/1110; fixed: @zkamvar, #397)

# sandpaper 0.11.5 (2023-02-09)

## BUG FIX
Expand Down
33 changes: 23 additions & 10 deletions R/utils-renv.R
@@ -1,6 +1,6 @@
#nocov start
# very internal function for me to burn everything down. This will remove
# the local library, local cache, and the entire {renv} cache.
# the local library, local cache, and the entire {renv} cache.
renv_burn_it_down <- function(path = ".", profile = "lesson-requirements") {
callr::r(function(path, profile) {
wd <- getwd()
Expand Down Expand Up @@ -68,7 +68,7 @@ renv_lockfile_hash <- function(path, db_path, profile = "lesson-requirements") {
#' been created or that consent has already been provided.)
#'
#' @param force if `TRUE`, consent is forced to be TRUE, creating the cache
#' directory if it did not exist before. Defaults to `FALSE`, which gently
#' directory if it did not exist before. Defaults to `FALSE`, which gently
#' inquires for consent.
#' @return a character vector
#' @keywords internal
Expand All @@ -85,7 +85,7 @@ try_use_renv <- function(force = FALSE) {
lines <- readLines(tmp)
if (force) {
lines <- lines[length(lines)]
}
}
invisible(lines)
}

Expand Down Expand Up @@ -128,7 +128,7 @@ renv_setup_profile <- function(path = ".", profile = "lesson-requirements") {
on.exit(setwd(wd))
setwd(path)
# NOTE: I do not know why, but this takes forever to run when no internet is
# available. Kevin may know why.
# available. Kevin may know why.
renv::init(project = path, bare = TRUE, restart = FALSE, profile = profile)
renv::deactivate(project = path)
},
Expand Down Expand Up @@ -157,7 +157,7 @@ renv_setup_profile <- function(path = ".", profile = "lesson-requirements") {
#' # install.packages("cowsay") # install cowsay to your lesson cache
#' # cowsay::say() # hello world
#' # detach('package:cowsay') # detach the package from your current session
#' done() # finish the session
#' done() # finish the session
#' # try(cowsay::say()) # this fails because it's not in your global library
#' print(.libPaths())
#' }
Expand Down Expand Up @@ -203,7 +203,7 @@ renv_diagnostics <- function(path = ".", profile = "lesson-requirements") {


renv_cache_available <- function() {
rccs <- renv::config$cache.symlinks()
rccs <- renv::config$cache.symlinks()
stf <- getOption("sandpaper.test_fixture")
if (is.null(rccs) && is.null(stf)) {
return("")
Expand Down Expand Up @@ -235,7 +235,7 @@ callr_manage_deps <- function(path, repos, snapshot, lockfile_exists) {
# Steps to update a {renv} environment regardless of whether or not the user
# has initiated {renv} in the first place
#
# 1. find the packages we need from the global library or elsewhere, and
# 1. find the packages we need from the global library or elsewhere, and
# load them into the profile's library
cli::cli_alert("Searching for and installing available dependencies")
#nocov start
Expand All @@ -254,14 +254,27 @@ callr_manage_deps <- function(path, repos, snapshot, lockfile_exists) {
}
#nocov end
if (needs_hydration) {
hydra <- renv::hydrate(packages = pkgs, library = renv_lib, update = FALSE,
hydra <- renv::hydrate(packages = pkgs, library = renv_lib, update = FALSE,
project = path)
#nocov start
# NOTE: I am not testing this now because this code requires yet another
# step to install packages. I will rely on the integration tests to help
# me out here.
#
# When we have missing packages, this will help to search for and install
# missing bioconductor packages, if this is the actual problem.
if (length(hydra$missing)) {
pkgs <- vapply(hydra$missing, function(pkg) pkg$package, character(1))
cli::cli_alert_warning("Attempting to install missing packages assuming bioc")
renv::install(paste0("bioc::", pkgs), library = renv_lib, project = path)
}
#nocov end
}
# 2. If the lockfile exists, we update the library to the versions that are
# recorded.
if (lockfile_exists) {
cli::cli_alert("Restoring any dependency versions")
res <- renv::restore(project = path, library = renv_lib,
res <- renv::restore(project = path, library = renv_lib,
lockfile = renv_lock, prompt = FALSE)
}
if (snapshot) {
Expand All @@ -272,7 +285,7 @@ callr_manage_deps <- function(path, repos, snapshot, lockfile_exists) {
invisible(utils::capture.output(renv::deactivate(project = path), type = "message"))
return(snap)
}, add = TRUE)
# 4. Snapshot the current state of the library to the lockfile to
# 4. Snapshot the current state of the library to the lockfile to
# synchronize
cli::cli_alert("Recording changes in lockfile")
snap <- renv::snapshot(project = path, lockfile = renv_lock, prompt = FALSE)
Expand Down

0 comments on commit e2e6603

Please sign in to comment.