From 697bebb62edfede5c3e1abb3e042cffd0c0fb35b Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Fri, 15 Sep 2023 00:50:20 -0800 Subject: [PATCH] GH-34105: [R] Provide extra output for failed builds (#37727) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Rationale for this change This is a replacement for the previous PR https://github.com/apache/arrow/pull/37698. The rationale for this PR is providing extra output for R package builds where the C++ build fails ### What changes are included in this PR? Update the system call to save output when building Arrow C++ from the R package and output it if it's failed ### Are these changes tested? No automated tests but the changes have been tested manually. ### Are there any user-facing changes? Yes, but only for users building the R package from source which is hopefully not common. * Closes: #34105 Lead-authored-by: Bryce Mecum Co-authored-by: Nic Crane Signed-off-by: Raúl Cumplido --- r/tools/nixlibs.R | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/r/tools/nixlibs.R b/r/tools/nixlibs.R index 90ea868ea3491..1eb80abcdf586 100644 --- a/r/tools/nixlibs.R +++ b/r/tools/nixlibs.R @@ -466,17 +466,25 @@ build_libarrow <- function(src_dir, dst_dir) { env_vars <- env_vars_as_string(env_var_list) cat("**** arrow", ifelse(quietly, "", paste("with", env_vars)), "\n") - status <- suppressWarnings(system( - paste(env_vars, "inst/build_arrow_static.sh"), - ignore.stdout = quietly, ignore.stderr = quietly + + build_log_path <- tempfile(fileext = ".log") + status <- suppressWarnings(system2( + "bash", + "inst/build_arrow_static.sh", + env = env_vars, + stdout = ifelse(quietly, build_log_path, ""), + stderr = ifelse(quietly, build_log_path, "") )) + if (status != 0) { # It failed :( - cat( - "**** Error building Arrow C++.", - ifelse(env_is("ARROW_R_DEV", "true"), "", "Re-run with ARROW_R_DEV=true for debug information."), - "\n" - ) + cat("**** Error building Arrow C++.", "\n") + if (quietly) { + cat("**** Printing contents of build log because the build failed", + "while ARROW_R_DEV was set to FALSE\n") + cat(readLines(build_log_path), sep = "\n") + cat("**** Complete build log may still be present at", build_log_path, "\n") + } } invisible(status) }