Skip to content

Commit

Permalink
respect R_PROFILE_USER in hydrate
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Aug 26, 2021
1 parent cbe48ed commit 04e7373
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: renv
Type: Package
Title: Project Environments
Version: 0.14.0-6
Version: 0.14.0-7
Authors@R: c(
person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com"),
person("RStudio, PBC", role = c("cph"))
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

# renv 0.15.0 (UNRELEASED)

* `renv` now respects the `R_PROFILE_USER` environment variable, in addition
to the `user.profile` configuration option, when considering whether the
user `.Rprofile` should be examined for package dependencies. (#821)

* The `renv` auto-loader can now be disabled by setting the environment
variable `RENV_AUTOLOADER_ENABLED = FALSE`. This can be useful if you'd like
to explicitly control how a project is loaded, e.g. by calling `renv::load()`
Expand Down
25 changes: 20 additions & 5 deletions R/hydrate.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,30 @@ renv_hydrate_filter_impl <- function(package, path, library, update) {

}

renv_hydrate_packages_rprofile <- function() {

enabled <-
identical(config$user.profile(), TRUE) &&
!renv_tests_running()

if (!enabled)
return()

rprofile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile")
if (!file.exists(rprofile))
return()

dependencies(rprofile, quiet = TRUE, dev = TRUE)

}

renv_hydrate_packages <- function(project, libpaths = NULL) {

deps <- dependencies(project, quiet = TRUE, dev = TRUE)

if (!renv_tests_running() && file.exists("~/.Rprofile")) {
profdeps <- dependencies("~/.Rprofile", quiet = TRUE, dev = TRUE)
if (length(deps))
deps <- bind_list(list(deps, profdeps))
}
profdeps <- renv_hydrate_packages_rprofile()
if (length(deps) && length(profdeps))
deps <- bind_list(list(deps, profdeps))

unique(deps$Package)

Expand Down
2 changes: 1 addition & 1 deletion R/load.R
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ renv_load_rprofile <- function(project = NULL) {

project <- renv_project_resolve(project)

enabled <- config$user.profile()
enabled <- identical(config$user.profile(), TRUE)
if (!enabled)
return(FALSE)

Expand Down

0 comments on commit 04e7373

Please sign in to comment.