From 564a674b6fd4af810885ab63349981ac55beb632 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 3 Sep 2024 17:18:11 -0600 Subject: [PATCH 1/3] Add attribute to `repos`, for renv users --- crates/ark/src/modules/positron/options.R | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/ark/src/modules/positron/options.R b/crates/ark/src/modules/positron/options.R index e475c0e38..40eef343f 100644 --- a/crates/ark/src/modules/positron/options.R +++ b/crates/ark/src/modules/positron/options.R @@ -27,8 +27,27 @@ options(device = function() { }) # Set cran mirror -repos <- getOption("repos") -rstudio_cran <- "https://cran.rstudio.com/" +set_cran_mirror <- function(repos) { + rstudio_cran <- "https://cran.rstudio.com/" + if (is.null(repos) || !is.character(repos)) { + return(c(CRAN = rstudio_cran)) + } else { + if ("CRAN" %in% names(repos)) { + if (identical(repos[["CRAN"]], "@CRAN@")) { + repos[["CRAN"]] <- rstudio_cran + return(repos) + } + } else { + return(c(CRAN = rstudio_cran, repos)) + } + } +} + +original_repos <- getOption("repos") +repos <- set_cran_mirror(original_repos) +attr(repos, "Positron") <- TRUE +options(repos = repos) + if (is.null(repos) || !is.character(repos)) { options(repos = c(CRAN = rstudio_cran)) From b6a56a9faa8f40f18309602c44275e13b2950a61 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Tue, 3 Sep 2024 18:19:57 -0600 Subject: [PATCH 2/3] Fix doubled up `options()` --- crates/ark/src/modules/positron/options.R | 30 ++++------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/crates/ark/src/modules/positron/options.R b/crates/ark/src/modules/positron/options.R index 40eef343f..871708430 100644 --- a/crates/ark/src/modules/positron/options.R +++ b/crates/ark/src/modules/positron/options.R @@ -27,41 +27,21 @@ options(device = function() { }) # Set cran mirror -set_cran_mirror <- function(repos) { - rstudio_cran <- "https://cran.rstudio.com/" - if (is.null(repos) || !is.character(repos)) { - return(c(CRAN = rstudio_cran)) - } else { - if ("CRAN" %in% names(repos)) { - if (identical(repos[["CRAN"]], "@CRAN@")) { - repos[["CRAN"]] <- rstudio_cran - return(repos) - } - } else { - return(c(CRAN = rstudio_cran, repos)) - } - } -} - -original_repos <- getOption("repos") -repos <- set_cran_mirror(original_repos) -attr(repos, "Positron") <- TRUE -options(repos = repos) - - +repos <- getOption("repos") +rstudio_cran <- "https://cran.rstudio.com/" if (is.null(repos) || !is.character(repos)) { - options(repos = c(CRAN = rstudio_cran)) + repos <- c(CRAN = rstudio_cran) } else { if ("CRAN" %in% names(repos)) { if (identical(repos[["CRAN"]], "@CRAN@")) { repos[["CRAN"]] <- rstudio_cran - options(repos = repos) } } else { repos <- c(CRAN = rstudio_cran, repos) - options(repos = repos) } } +attr(repos, "Positron") <- TRUE +options(repos = repos) # Show Plumber apps in the viewer options(plumber.docs.callback = function(url) { From b965820349b7805e5363171502e2161b9d799912 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Wed, 4 Sep 2024 15:26:39 -0600 Subject: [PATCH 3/3] Only attribute if we detect `@CRAN@`, use "IDE" for attribute --- crates/ark/src/modules/positron/options.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ark/src/modules/positron/options.R b/crates/ark/src/modules/positron/options.R index 871708430..69478dbc9 100644 --- a/crates/ark/src/modules/positron/options.R +++ b/crates/ark/src/modules/positron/options.R @@ -35,12 +35,12 @@ if (is.null(repos) || !is.character(repos)) { if ("CRAN" %in% names(repos)) { if (identical(repos[["CRAN"]], "@CRAN@")) { repos[["CRAN"]] <- rstudio_cran + attr(repos, "IDE") <- TRUE } } else { repos <- c(CRAN = rstudio_cran, repos) } } -attr(repos, "Positron") <- TRUE options(repos = repos) # Show Plumber apps in the viewer