From 065ca0a2466868b22f83f024744e2fcbd138359c Mon Sep 17 00:00:00 2001 From: lz Date: Tue, 2 Mar 2021 14:45:06 -0800 Subject: [PATCH 1/3] move sudo outside --- R/system-requirements.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/R/system-requirements.R b/R/system-requirements.R index dfa10cb84..1c0c49965 100644 --- a/R/system-requirements.R +++ b/R/system-requirements.R @@ -116,11 +116,12 @@ system_requirements_internal <- function(os, os_release, root, package, execute, callback <- function(x, ...) invisible() } + if (sudo) { + cmd <- paste("sudo", cmd) + } + if (execute) { for (cmd in commands) { - if (sudo) { - cmd <- paste("sudo", cmd) - } cli::cli_alert_info("Executing {.code {cmd}}") processx::run("sh", c("-c", cmd), stdout_callback = callback, stderr_to_stdout = TRUE) From 27eac9ad058ae69ce08d94aa20141db9dc52e45d Mon Sep 17 00:00:00 2001 From: lz Date: Tue, 2 Mar 2021 15:30:22 -0800 Subject: [PATCH 2/3] fix length 0 problem --- R/system-requirements.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/system-requirements.R b/R/system-requirements.R index 1c0c49965..30909ec0e 100644 --- a/R/system-requirements.R +++ b/R/system-requirements.R @@ -116,8 +116,8 @@ system_requirements_internal <- function(os, os_release, root, package, execute, callback <- function(x, ...) invisible() } - if (sudo) { - cmd <- paste("sudo", cmd) + if (all(sudo, length(commands))) { + commands <- paste("sudo", commands) } if (execute) { From 23961e81d2fb497c522379480dc5f79d18d739c6 Mon Sep 17 00:00:00 2001 From: LeZhang <35240440+lz100@users.noreply.github.com> Date: Wed, 3 Mar 2021 17:53:57 -0300 Subject: [PATCH 3/3] accept suggestion Co-authored-by: Jim Hester --- R/system-requirements.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/system-requirements.R b/R/system-requirements.R index 30909ec0e..721c35bcb 100644 --- a/R/system-requirements.R +++ b/R/system-requirements.R @@ -116,7 +116,7 @@ system_requirements_internal <- function(os, os_release, root, package, execute, callback <- function(x, ...) invisible() } - if (all(sudo, length(commands))) { + if (sudo && length(commands) > 0) { commands <- paste("sudo", commands) }