From bdf0426249eea1dcd32cb025246441b4453374eb Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 25 May 2022 16:21:41 +0100 Subject: [PATCH 1/2] fix renv bug --- NEWS.md | 4 ++++ R/git_tools.R | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index cf73d57..2336ab5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# staged.dependencies 0.2.6 + +* Fixed bug whereby `renv` did not recognize internal dependencies already installed. + # staged.dependencies 0.2.5 * Added `renv_files` element into `dependency_structure` object to capture (in JSON) the renv.lock files from internal dependencies for future processing. The `renv_profile` argument to `dependency_table` allows you to choose which renv profile to include if not using the default one. diff --git a/R/git_tools.R b/R/git_tools.R index 95d3e25..2dc1d2f 100644 --- a/R/git_tools.R +++ b/R/git_tools.R @@ -175,13 +175,20 @@ install_external_deps <- function(repo_dir, internal_pkg_deps, ...) { # remove internal_pkg_deps from DESCRIPTION file desc_obj <- desc::desc(file.path(repo_dir_external, "DESCRIPTION")) new_deps <- desc_obj$get_deps()[!desc_obj$get_deps()$package %in% internal_pkg_deps,] - desc_obj$set_deps(new_deps) - desc_obj$write() + if (!is.null(Sys.getenv("RENV_PROJECT")) && Sys.getenv("RENV_PROJECT") != "" && requireNamespace("renv", quietly = TRUE)) { + # renv::install installs the package not just the dependencies + # in this case we do not want the package to be installed (as it overwrites + # the sha which is needed to make sure the internal dependencies have not changed) + temp_package_name <- paste0(desc_obj$get("Package"), ".dependencies") + desc_obj$set("Package", paste(temp_package_name)) + desc_obj$write() renv::install(repo_dir_external) + suppressMessages(utils::remove.packages(temp_package_name)) } else { + desc_obj$write() remotes::install_deps(repo_dir_external, ...) } } From cef49e630b1524f0de298cfa1a6ea02e845117c7 Mon Sep 17 00:00:00 2001 From: Nikolas Burkoff Date: Wed, 25 May 2022 16:23:41 +0100 Subject: [PATCH 2/2] update version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4d3a574..28698bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: staged.dependencies Type: Package Title: Install R packages from Particular Git Branches -Version: 0.2.5 +Version: 0.2.6 Authors@R: c( person("Adrian", "Waddell", email = "adrian.waddell@roche.com", role = c("aut", "cre")), person("Maximilian", "Mordig", email = "maximilian_oliver.mordig@roche.com", role = "aut"),