From 5dc2fc934867a1b34ec9d1c594dc57d3c9698650 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 10 Aug 2023 09:43:40 -0700 Subject: [PATCH] renv 1.0.1 (#1639) * polish NEWS * update README * Try to make sure sandbox unlocked at end * fixup * version update * use scoped sandbox consistently * a couple more skips --- DESCRIPTION | 2 +- NEWS.md | 18 ++++++++++-------- README.md | 10 +++++----- tests/testthat.R | 11 ++++++----- tests/testthat/helper-setup.R | 8 ++++++++ tests/testthat/test-ppm.R | 6 ++++++ tests/testthat/test-sandbox.R | 20 +++++++++++--------- 7 files changed, 47 insertions(+), 28 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a97e07f0c..c1c650d33 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: renv Type: Package Title: Project Environments -Version: 1.0.0.9000 +Version: 1.0.1 Authors@R: c( person("Kevin", "Ushey", role = c("aut", "cre"), email = "kevin@rstudio.com", comment = c(ORCID = "0000-0003-2880-7407")), diff --git a/NEWS.md b/NEWS.md index d3035aad2..2941c1eba 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,13 +1,13 @@ -# renv 1.1.0 (UNRELEASED) +# renv 1.0.1 * Fixed an issue where authentication headers could be duplicated when using the `libcurl` download method. (#1605) * `renv::use()` now defaults to setting `isolate = TRUE` when `sandbox = TRUE`. -* Fixed an issue where the renv watchdog could fail to load when not installed - into the user library. (#1617) +* Fixed an issue where the renv watchdog could fail to load, leading to slowness + in activating the sandbox on startup. (#1617) * Fixed an issue where renv did not display warnings / errors from `renv::snapshot()` when `options(renv.verbose = FALSE)` was set. The display of these messages @@ -32,7 +32,7 @@ * Fixed a logic error in reading `RENV_AUTOLOAD_ENABLED`. (#1580) * `renv::restore()` no longer runs without prompting on load if the - library is empty (#1543). + library is empty. (#1543) * `renv::repair()` now checks for installed packages which lack a known remote source, and updates their `DESCRIPTION` files if it can infer an @@ -42,11 +42,11 @@ we've rolled back that change as the prompting was over-aggressive. (#1574) * `renv::status()` now first reports on uninstalled packages, before reporting on - used <-> installed mismatches (#1538). + used <-> installed mismatches. (#1538) * When the `RENV_STARTUP_DIAGNOSTICS` environment variable is set to `TRUE`, - `renv` now displays a short diagnostics report after a project's autoloader - has been run. This can be useful when diagnosing why `renv` is slow to load + renv now displays a short diagnostics report after a project's autoloader + has been run. This can be useful when diagnosing why renv is slow to load in certain projects. (#1557) * renv now ensures the sandbox is activated on load, for R processes which @@ -64,7 +64,8 @@ * Use correct spelling of IRkernel package (#1528). * Honor `R_LIBCURL_SSL_REVOKE_BEST_EFFORT` when using an external `curl.exe` - binary to download files (#1624) + binary to download files. (#1624) + # renv 1.0.0 @@ -207,6 +208,7 @@ * renv functions give a clearer error if `renv.lock` has somehow become corrupted (#1027). + # renv 0.17.3 * Fixed an issue where `renv::install("bioc::")` could fail if diff --git a/README.md b/README.md index 343c5d8b7..1da0963a1 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ for your R projects. Use renv to make your R projects more isolated, portable and reproducible. - **Isolated**: Installing a new or updated package for one project - won't break your other projects, and vice versa. That's because renv + won’t break your other projects, and vice versa. That’s because renv gives each project its own private library. - **Portable**: Easily transport your projects from one computer to another, even across different platforms. renv makes it easy to @@ -42,14 +42,14 @@ install.packages("renv") A diagram showing the most important verbs and nouns of renv. Projects start with init(), which creates a project library using packages from the system library. snapshot() updates the lockfile using the packages installed in the project library, where restore() installs packages into the project library using the metadata from the lockfile, and status() compares the lockfile to the project library. You install and update packages from CRAN and GitHub using install() and update(), but because you'll need to do this for multiple projects, renv uses cache to make this fast. Use `renv::init()` to initialize renv in a new or existing project. This -will set up up **project library**, containing all the packages you're +will set up up **project library**, containing all the packages you’re currently using. The packages (and all the metadata needed to reinstall them) are recorded into a **lockfile**, `renv.lock`, and a `.Rprofile` ensures that the library is used every time you open that project. As you continue to work on your project, you will install and upgrade packages, either using `install.packages()` and `update.packages` or -`renv::install()` and `renv::update()`. After you've confirmed your code +`renv::install()` and `renv::update()`. After you’ve confirmed your code works as expected, use `renv::snapshot()` to record the packages and their sources in the lockfile. @@ -66,10 +66,10 @@ will help you understand the most important verbs and nouns of renv. If you have a question about renv, please first check the [FAQ](https://rstudio.github.io/renv/articles/faq.html) to see whether -your question has already been addressed. If it hasn't, please feel free +your question has already been addressed. If it hasn’t, please feel free to ask on the [RStudio Community forums](https://community.rstudio.com). -If you believe you've found a bug in renv, please file a bug (and, if +If you believe you’ve found a bug in renv, please file a bug (and, if possible, a [reproducible example](https://reprex.tidyverse.org)) at . diff --git a/tests/testthat.R b/tests/testthat.R index f4a94e7c7..247b10987 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,9 +1,10 @@ + library(testthat) library(renv, warn.conflicts = FALSE) -if (renv:::renv_tests_supported()) { - # renv:::renv_tests_diagnostics() - test_check("renv") -} else { - message("renv does not support running tests on this platform.") +if (!renv:::renv_tests_supported()) { + message("* renv does not support running tests on this platform.") + if (!interactive()) quit(status = 0L) } + +test_check("renv") diff --git a/tests/testthat/helper-setup.R b/tests/testthat/helper-setup.R index 3845f25f3..b664597c0 100644 --- a/tests/testthat/helper-setup.R +++ b/tests/testthat/helper-setup.R @@ -28,6 +28,9 @@ renv_tests_setup <- function(scope = parent.frame()) { # fix up the library paths if needed for testing renv_tests_setup_libpaths(scope = scope) + # make sure we clean up sandbox on exit + renv_tests_setup_sandbox(scope = scope) + # initialize test repositories renv_tests_setup_repos(scope = scope) @@ -140,6 +143,11 @@ renv_tests_setup_libpaths <- function(scope = parent.frame()) { } +renv_tests_setup_sandbox <- function(scope = parent.frame()) { + renv_scope_options(renv.sandbox.locking_enabled = FALSE) + defer(renv_sandbox_unlock(), scope = scope) +} + renv_tests_setup_repos <- function(scope = parent.frame()) { # generate our dummy repository diff --git a/tests/testthat/test-ppm.R b/tests/testthat/test-ppm.R index 3ed05ed25..985174fa2 100644 --- a/tests/testthat/test-ppm.R +++ b/tests/testthat/test-ppm.R @@ -56,6 +56,8 @@ test_that("RSPM is confirmed not supported on trusty", { }) test_that("renv correctly detects RHEL as CentOS for RSPM", { + skip_on_cran() + skip_on_os("windows") release <- heredoc(' NAME="Red Hat Enterprise Linux Server" @@ -81,6 +83,8 @@ test_that("renv correctly detects RHEL as CentOS for RSPM", { }) test_that("URLs like http://foo/bar aren't queried", { + skip_on_cran() + skip_on_os("windows") # pretend to be Ubuntu renv_scope_envvars( @@ -103,6 +107,8 @@ test_that("URLs like http://foo/bar aren't queried", { }) test_that("renv_ppm_transform() uses source URLs when appropriate", { + skip_on_cran() + skip_on_os("windows") # pretend to be Ubuntu renv_scope_envvars( diff --git a/tests/testthat/test-sandbox.R b/tests/testthat/test-sandbox.R index 0a2d942b0..d87dba392 100644 --- a/tests/testthat/test-sandbox.R +++ b/tests/testthat/test-sandbox.R @@ -7,16 +7,16 @@ renv_scoped_sandbox <- function(scope = parent.frame()) { old <- list(.Library.site, .Library, .libPaths()) defer(scope = scope, { - renv_binding_replace(base, ".Library.site", old[[1]]) - renv_binding_replace(base, ".Library", old[[2]]) + unlink(sandbox, recursive = TRUE, force = TRUE) + renv_binding_replace(base, ".Library.site", old[[1L]]) + renv_binding_replace(base, ".Library", old[[2L]]) .libPaths(old[[3]]) }) } test_that("the sandbox can be activated and deactivated", { - renv_scope_options(renv.config.sandbox.enabled = TRUE) - renv_scope_envvars(RENV_PATHS_SANDBOX = tempdir()) + renv_scoped_sandbox() # save current library paths libpaths <- .libPaths() @@ -37,8 +37,7 @@ test_that("the sandbox can be activated and deactivated", { test_that("multiple attempts to activate sandbox are handled", { - renv_scope_options(renv.config.sandbox.enabled = TRUE) - renv_scope_envvars(RENV_PATHS_SANDBOX = tempdir()) + renv_scoped_sandbox() libpaths <- .libPaths() syslib <- renv_libpaths_system() @@ -61,7 +60,9 @@ test_that(".Library.site isn't used even when sandbox is disabled", { skip_if(renv_platform_windows() || empty(.Library.site)) renv_scope_options(renv.config.sandbox.enabled = FALSE) - renv_scope_envvars(RENV_PATHS_SANDBOX = tempdir()) + + sandbox <- renv_scope_tempfile("renv-sandbox-") + renv_scope_envvars(RENV_PATHS_SANDBOX = sandbox) sitelib <- setdiff(.Library.site, .Library) renv_sandbox_activate() @@ -72,8 +73,7 @@ test_that(".Library.site isn't used even when sandbox is disabled", { test_that("renv repairs library paths on load if sandbox is active", { - renv_scope_options(renv.config.sandbox.enabled = TRUE) - renv_scope_envvars(RENV_PATHS_SANDBOX = tempdir()) + renv_scoped_sandbox() libpaths <- .libPaths() syslib <- renv_libpaths_system() @@ -116,6 +116,8 @@ test_that("multiple processes can attempt to acquire the sandbox", { skip_on_cran() skip_on_ci() + renv_scoped_sandbox() + # number of processes n <- 20