22local({
33
44 # the requested version of renv
5- version <- " 1.1.5"
5+ version <- " 1.1.7"
6+ attr(version , " md5" ) <- " dd5d60f155dadff4c88c2fc6680504b4"
67 attr(version , " sha" ) <- NULL
78
89 # the project directory
@@ -168,6 +169,16 @@ local({
168169 if (quiet )
169170 return (invisible ())
170171
172+ # also check for config environment variables that should suppress messages
173+ # https://github.com/rstudio/renv/issues/2214
174+ enabled <- Sys.getenv(" RENV_CONFIG_STARTUP_QUIET" , unset = NA )
175+ if (! is.na(enabled ) && tolower(enabled ) %in% c(" true" , " 1" ))
176+ return (invisible ())
177+
178+ enabled <- Sys.getenv(" RENV_CONFIG_SYNCHRONIZED_CHECK" , unset = NA )
179+ if (! is.na(enabled ) && tolower(enabled ) %in% c(" false" , " 0" ))
180+ return (invisible ())
181+
171182 msg <- sprintf(fmt , ... )
172183 cat(msg , file = stdout(), sep = if (appendLF ) " \n " else " " )
173184
@@ -215,6 +226,16 @@ local({
215226 section <- header(sprintf(" Bootstrapping renv %s" , friendly ))
216227 catf(section )
217228
229+ # try to install renv from cache
230+ md5 <- attr(version , " md5" , exact = TRUE )
231+ if (length(md5 )) {
232+ pkgpath <- renv_bootstrap_find(version )
233+ if (length(pkgpath ) && file.exists(pkgpath )) {
234+ file.copy(pkgpath , library , recursive = TRUE )
235+ return (invisible ())
236+ }
237+ }
238+
218239 # attempt to download renv
219240 catf(" - Downloading renv ... " , appendLF = FALSE )
220241 withCallingHandlers(
@@ -240,7 +261,6 @@ local({
240261
241262 # add empty line to break up bootstrapping from normal output
242263 catf(" " )
243-
244264 return (invisible ())
245265 }
246266
@@ -257,12 +277,20 @@ local({
257277 repos <- Sys.getenv(" RENV_CONFIG_REPOS_OVERRIDE" , unset = NA )
258278 if (! is.na(repos )) {
259279
260- # check for RSPM; if set, use a fallback repository for renv
261- rspm <- Sys.getenv(" RSPM" , unset = NA )
262- if (identical(rspm , repos ))
263- repos <- c(RSPM = rspm , CRAN = cran )
280+ # split on ';' if present
281+ parts <- strsplit(repos , " ;" , fixed = TRUE )[[1L ]]
264282
265- return (repos )
283+ # split into named repositories if present
284+ idx <- regexpr(" =" , parts , fixed = TRUE )
285+ keys <- substring(parts , 1L , idx - 1L )
286+ vals <- substring(parts , idx + 1L )
287+ names(vals ) <- keys
288+
289+ # if we have a single unnamed repository, call it CRAN
290+ if (length(vals ) == 1L && identical(keys , " " ))
291+ names(vals ) <- " CRAN"
292+
293+ return (vals )
266294
267295 }
268296
@@ -511,6 +539,51 @@ local({
511539
512540 }
513541
542+ renv_bootstrap_find <- function (version ) {
543+
544+ path <- renv_bootstrap_find_cache(version )
545+ if (length(path ) && file.exists(path )) {
546+ catf(" - Using renv %s from global package cache" , version )
547+ return (path )
548+ }
549+
550+ }
551+
552+ renv_bootstrap_find_cache <- function (version ) {
553+
554+ md5 <- attr(version , " md5" , exact = TRUE )
555+ if (is.null(md5 ))
556+ return ()
557+
558+ # infer path to renv cache
559+ cache <- Sys.getenv(" RENV_PATHS_CACHE" , unset = " " )
560+ if (! nzchar(cache )) {
561+ root <- Sys.getenv(" RENV_PATHS_ROOT" , unset = NA )
562+ if (! is.na(root ))
563+ cache <- file.path(root , " cache" )
564+ }
565+
566+ if (! nzchar(cache )) {
567+ tools <- asNamespace(" tools" )
568+ if (is.function(tools $ R_user_dir )) {
569+ root <- tools $ R_user_dir(" renv" , " cache" )
570+ cache <- file.path(root , " cache" )
571+ }
572+ }
573+
574+ # start completing path to cache
575+ file.path(
576+ cache ,
577+ renv_bootstrap_cache_version(),
578+ renv_bootstrap_platform_prefix(),
579+ " renv" ,
580+ version ,
581+ md5 ,
582+ " renv"
583+ )
584+
585+ }
586+
514587 renv_bootstrap_download_tarball <- function (version ) {
515588
516589 # if the user has provided the path to a tarball via
@@ -979,7 +1052,7 @@ local({
9791052
9801053 renv_bootstrap_validate_version_release <- function (version , description ) {
9811054 expected <- description [[" Version" ]]
982- is.character(expected ) && identical(expected , version )
1055+ is.character(expected ) && identical(c( expected ), c( version ) )
9831056 }
9841057
9851058 renv_bootstrap_hash_text <- function (text ) {
@@ -1181,6 +1254,18 @@ local({
11811254
11821255 }
11831256
1257+ renv_bootstrap_cache_version <- function () {
1258+ # NOTE: users should normally not override the cache version;
1259+ # this is provided just to make testing easier
1260+ Sys.getenv(" RENV_CACHE_VERSION" , unset = " v5" )
1261+ }
1262+
1263+ renv_bootstrap_cache_version_previous <- function () {
1264+ version <- renv_bootstrap_cache_version()
1265+ number <- as.integer(substring(version , 2L ))
1266+ paste(" v" , number - 1L , sep = " " )
1267+ }
1268+
11841269 renv_json_read <- function (file = NULL , text = NULL ) {
11851270
11861271 jlerr <- NULL
0 commit comments