From 4edf1e440ba26b925e6bb573cf278d50d4857572 Mon Sep 17 00:00:00 2001 From: Sam Rogers Date: Fri, 1 Dec 2023 15:15:35 +1030 Subject: [PATCH] Updating asking password for macOS --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/install_asreml.R | 10 ++++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3cb596d..85e7261 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,6 +38,7 @@ Depends: R (>= 4.0.0) Imports: agricolae, + askpass, cowplot, xml2, emmeans, @@ -52,7 +53,6 @@ Imports: Suggests: covr, crayon, - getPass, knitr, mockery, rmarkdown, diff --git a/NAMESPACE b/NAMESPACE index 71081e2..c3c647f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,6 +13,7 @@ export(resplot) export(resplt) export(update_asreml) export(variogram) +importFrom(askpass,askpass) importFrom(cowplot,add_sub) importFrom(cowplot,plot_grid) importFrom(curl,curl_fetch_disk) diff --git a/R/install_asreml.R b/R/install_asreml.R index fa5455c..03fefd6 100644 --- a/R/install_asreml.R +++ b/R/install_asreml.R @@ -38,6 +38,10 @@ install_asreml <- function(library = .libPaths()[1], quiet = FALSE, force = FALS # Get OS and R version os_ver <- get_r_os() + if(os_ver$os=="mac") { + create_mac_folder() + } + url <- paste0("https://link.biometryhubwaite.com/", os_ver$os_ver) # First check if file already exists, both in the current directory and temp folder @@ -269,6 +273,7 @@ compare_versions <- function() { #' #' @return logical; TRUE if folder successfully created, otherwise it will error #' @keywords internal +#' @importFrom askpass askpass create_mac_folder <- function() { # macOS needs some special set up if(Sys.info()[["sysname"]] == "Darwin" && @@ -290,9 +295,10 @@ create_mac_folder <- function() { message("The ASReml-R package uses Reprise license management and will require administrator privilege to create the folder '/Library/Application Support/Reprise' before it can be installed.") input <- readline("Would you like to create this folder now (Yes/No)? You will be prompted for your password if yes. ") - if(toupper(input) %in% c("YES", "Y") && rlang::is_installed("getPass")) { + if(toupper(input) %in% c("YES", "Y")) { system("sudo -S mkdir '/Library/Application Support/Reprise' && sudo -S chmod 777 '/Library/Application Support/Reprise'", - input = getPass::getPass("Please enter your user account password: ")) + input = askpass::askpass("Please enter your user account password: ")) + cat("\n") } else { stop("ASReml-R cannot be installed until the folder '/Library/Application Support/Reprise' is created with appropriate permissions.