Skip to content

Commit

Permalink
ensure that 'renv.project.path' is set when loading project
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Nov 18, 2024
1 parent b531b02 commit e56cf7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# renv 1.1.0 (UNRELEASED)

* Fixed an issue where `renv` library paths were not properly reset following
a suspend / resume in RStudio Server. (#2036)

* `renv::run()` gains the `args` parameter, which can be used to pass command-line
arguments to a script. (#2015)

Expand Down
6 changes: 5 additions & 1 deletion R/project.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ renv_project_get <- function(default = NULL) {
the$project_path %||% default
}

# NOTE: RENV_PROJECT kept for backwards compatibility with RStudio
# NOTE: 'RENV_PROJECT' kept for backwards compatibility with RStudio
renv_project_set <- function(project) {
the$project_path <- project
# https://github.com/rstudio/renv/issues/2036
options(renv.project.path = project)
Sys.setenv(RENV_PROJECT = project)
}

# NOTE: 'RENV_PROJECT' kept for backwards compatibility with RStudio
renv_project_clear <- function() {
the$project_path <- NULL
# https://github.com/rstudio/renv/issues/2036
options(renv.project.path = NULL)
Sys.unsetenv("RENV_PROJECT")
}

Expand Down
9 changes: 7 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@

# if an renv project already appears to be loaded, then re-activate
# the sandbox now -- this is primarily done to support suspend and
# resume with RStudio where the user profile might not be run
# resume with RStudio where the user profile might not have been run,
# but RStudio would have restored options from the prior session
#
# https://github.com/rstudio/renv/issues/2036
if (renv_rstudio_available()) {
project <- getOption("renv.project.path")
if (!is.null(project))
if (!is.null(project)) {
renv_project_set(project)
renv_sandbox_activate(project = project)
}
}

# make sure renv is unloaded on exit, so locks etc. are released
Expand Down

0 comments on commit e56cf7f

Please sign in to comment.