diff --git a/R/diagnostic_test.R b/R/diagnostic_test.R index 73921b5..eb84bf4 100644 --- a/R/diagnostic_test.R +++ b/R/diagnostic_test.R @@ -103,16 +103,16 @@ check_renv_download_method <- function( } rdm_present <- .renviron %>% stringr::str_detect("RENV_DOWNLOAD_METHOD") if (any(rdm_present)) { - dfeR::toggle_message( - "Found RENV_DOWNLOAD_METHOD in .Renviron:", - verbose = verbose + current_setting_message <- paste0( + "RENV_DOWNLOAD_METHOD is currently set to:\n ", + .renviron[rdm_present] ) - dfeR::toggle_message(" ", .renviron[rdm_present], verbose = verbose) detected_method <- .renviron[rdm_present] |> stringr::str_split("=") |> unlist() |> magrittr::extract(2) } else { + current_setting_message <- "RENV_DOWNLOAD_METHOD is not currently set." detected_method <- NA } if (is.na(detected_method) || detected_method != "\"curl\"") { @@ -133,6 +133,9 @@ check_renv_download_method <- function( ) readRenviron(renviron_file) } else { + dfeR::toggle_message(current_setting_message, + verbose = verbose + ) message("If you wish to manually update your .Renviron file:") message(" - Run the command in the R console to open .Renviron:") message(" usethis::edit_r_environ()") @@ -142,6 +145,7 @@ check_renv_download_method <- function( } message(" - Add the following line to .Renviron:") message(" RENV_DOWNLOAD_METHOD=\"curl\"") + message("Or run `dfeR::check_renv_download_method(clean=TRUE)`") } } else { message("PASS: Your RENV_DOWNLOAD_METHOD is set to curl.") diff --git a/man/check_proxy_settings.Rd b/man/check_proxy_settings.Rd index 0832160..bcf49c2 100644 --- a/man/check_proxy_settings.Rd +++ b/man/check_proxy_settings.Rd @@ -11,8 +11,8 @@ check_proxy_settings( ) } \arguments{ -\item{proxy_setting_names}{Vector of proxy parameters to check for. Default: c("http.proxy", -"https.proxy")} +\item{proxy_setting_names}{Vector of proxy parameters to check for. Default: +c("http.proxy", "https.proxy")} \item{clean}{Attempt to clean settings} @@ -22,7 +22,11 @@ check_proxy_settings( List of problem proxy settings } \description{ -Check proxy settings +This script checks for "bad" proxy settings. Prior to the pandemic, analysts +in the DfE would need to add some proxy settings to their GitHub config. +These settings now prevent Git from connecting to remote archives on GitHub +and Azure DevOps if present, so this script identifies and (if clean=TRUE is +set) removes them. } \examples{ \dontrun{ diff --git a/man/check_renv_download_method.Rd b/man/check_renv_download_method.Rd index ad9a47c..5ec319f 100644 --- a/man/check_renv_download_method.Rd +++ b/man/check_renv_download_method.Rd @@ -6,7 +6,6 @@ \usage{ check_renv_download_method( renviron_file = "~/.Renviron", - user_input = TRUE, clean = FALSE, verbose = FALSE ) @@ -22,7 +21,10 @@ check_renv_download_method( List object containing RENV_DOWNLOAD_METHOD } \description{ -Check renv download method +The renv package can retrieve packages either using curl or wininet, but +wininet doesn't work from within the DfE network. This script checks for +the parameter controlling which of these is used (RENV_DOWNLOAD_METHOD) and +sets it to use curl. } \examples{ check_renv_download_method() diff --git a/man/diagnostic_test.Rd b/man/diagnostic_test.Rd index e261a02..3bbf2fc 100644 --- a/man/diagnostic_test.Rd +++ b/man/diagnostic_test.Rd @@ -15,7 +15,8 @@ diagnostic_test(clean = FALSE, verbose = FALSE) List object of detected parameters } \description{ -Run a set of diagnostic tests to check for common issues found when setting up R on a DfE +Run a set of diagnostic tests to check for common issues found when setting +up R on a DfE system. This includes: \itemize{ \item Checking for proxy settings in the Git configuration diff --git a/tests/testthat/test-diagnostic_test.R b/tests/testthat/test-diagnostic_test.R index 2ed3b00..5e21c50 100644 --- a/tests/testthat/test-diagnostic_test.R +++ b/tests/testthat/test-diagnostic_test.R @@ -28,3 +28,15 @@ test_that("Check proxy settings identifies and removes proxy setting", { purrr::keep(list(x = NULL), names(list(x = NULL)) != "x") ) }) + +test_that("Check RENV_DOWNLOAD_METHOD", { + # Check that check_proxy_settings identifies the rogue entry + expect_equal( + check_renv_download_method( + ".Renviron_test", + clean = FALSE + ) |> + suppressMessages(), + list(RENV_DOWNLOAD_METHOD = NA) + ) +})