This is an automated email from the ASF dual-hosted git repository.
assignuser pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new e543ee69c9 GH-38752: [R] Wrap rosetta detection in tryCatch (#38754)
e543ee69c9 is described below
commit e543ee69c96062dcd6afb239b5b9c53b178d357c
Author: Jonathan Keane <[email protected]>
AuthorDate: Thu Nov 16 18:57:24 2023 -0600
GH-38752: [R] Wrap rosetta detection in tryCatch (#38754)
### Rationale for this change
We should never allow rosetta checking from causing an error
### What changes are included in this PR?
~Wrap rosetta checking in a tryCatch~ our use of `try()` wasn't doing what
we thought, it actually needs to have `silent = TRUE` specified to _not_ error.
### Are these changes tested?
I tested them locally by manipulating the system call to a mangled command
that doesn't exist, observing the error on load, then wrapping in trycatch. We
might consider adding a test in CI, though there would be considerable
complexity for something like that
### Are there any user-facing changes?
No, though we will need to pull it into any point release
* Closes: #38752
Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Jacob Wujciak-Jens <[email protected]>
---
r/R/arrow-package.R | 2 +-
r/R/install-arrow.R | 10 ++++++++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R
index eec95b8282..1f39a50744 100644
--- a/r/R/arrow-package.R
+++ b/r/R/arrow-package.R
@@ -212,7 +212,7 @@ configure_tzdb <- function() {
)
)
}
- })
+ }, silent = TRUE)
}
# Clean up the StopSource that was registered in .onLoad() so that if the
diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R
index 6db6f2b0ad..88eb61a5da 100644
--- a/r/R/install-arrow.R
+++ b/r/R/install-arrow.R
@@ -271,6 +271,12 @@ wslify_path <- function(path) {
on_rosetta <- function() {
# make sure to suppress warnings and ignore the stderr so that this is
silent where proc_translated doesn't exist
- identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
- identical(suppressWarnings(system("sysctl -n sysctl.proc_translated",
intern = TRUE, ignore.stderr = TRUE)), "1")
+ sysctl_out <- tryCatch(
+ suppressWarnings(system("sysctl -n sysctl.proc_translated", intern = TRUE,
ignore.stderr = TRUE)),
+ error = function(e) {
+ # If this has errored, we assume that this is not on rosetta
+ return("0")
+ }
+ )
+ identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
identical(sysctl_out, "1")
}