Skip to content

Commit

Permalink
Updating asking password for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Rogers authored and Sam Rogers committed Dec 1, 2023
1 parent b6021af commit 4edf1e4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Depends:
R (>= 4.0.0)
Imports:
agricolae,
askpass,
cowplot,
xml2,
emmeans,
Expand All @@ -52,7 +53,6 @@ Imports:
Suggests:
covr,
crayon,
getPass,
knitr,
mockery,
rmarkdown,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions R/install_asreml.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" &&
Expand All @@ -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.
Expand Down

0 comments on commit 4edf1e4

Please sign in to comment.