Skip to content

Commit

Permalink
Merge pull request #157 from openpharma/renv_fix
Browse files Browse the repository at this point in the history
Fix renv bug
  • Loading branch information
Nikolas Burkoff authored May 27, 2022
2 parents 1d65d8b + cef49e6 commit fbf6cfc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut", "cre")),
person("Maximilian", "Mordig", email = "[email protected]", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
11 changes: 9 additions & 2 deletions R/git_tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...)
}
}
Expand Down

0 comments on commit fbf6cfc

Please sign in to comment.