This is an automated email from the ASF dual-hosted git repository.
jonkeane 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 64ad8e564e GH-33807: [R] Add a message if we detect running under
emulation (#37777)
64ad8e564e is described below
commit 64ad8e564ea013101b8565ce200e54e5c85bac8d
Author: Jonathan Keane <[email protected]>
AuthorDate: Tue Sep 19 11:15:27 2023 -0500
GH-33807: [R] Add a message if we detect running under emulation (#37777)
Resolves #33807 and #37034
### Rationale for this change
If someone is running R under emulation, arrow segfaults without error. We
can detect this when we load so can also warn people that this is not
recommended. Though the version of R being run is not directly an arrow issue,
arrow fails very quickly in this configuration.
### What changes are included in this PR?
Detect when running under rosetta (on macOS only) and warn when the library
is attached
### Are these changes tested?
No, given the paucity of ARM-based mac CI, testing this organically would
be difficult. But the logic is straightforward.
### Are there any user-facing changes?
Yes, a warning when someone loads arrow under emulation.
* Closes: #33807
Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Jonathan Keane <[email protected]>
---
r/R/arrow-package.R | 21 +++++++++++++++++++++
r/R/install-arrow.R | 4 +---
r/README.md | 2 ++
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R
index 8f44f8936b..09183250ba 100644
--- a/r/R/arrow-package.R
+++ b/r/R/arrow-package.R
@@ -183,6 +183,22 @@ configure_tzdb <- function() {
# Just to be extra safe, let's wrap this in a try();
# we don't want a failed startup message to prevent the package from loading
try({
+ # On MacOS only, Check if we are running in under emulation, and warn
this will not work
+ if (on_rosetta()) {
+ packageStartupMessage(
+ paste(
+ "Warning:",
+ " It appears that you are running R and Arrow in emulation (i.e.
you're",
+ " running an Intel version of R on a non-Intel mac). This
configuration is",
+ " not supported by arrow, you should install a native (arm64) build
of R",
+ " and use arrow with that. See
https://cran.r-project.org/bin/macosx/",
+ "",
+ sep = "\n"
+ )
+ )
+ }
+
+
features <- arrow_info()$capabilities
# That has all of the #ifdef features, plus the compression libs and the
# string libraries (but not the memory allocators, they're added elsewhere)
@@ -225,6 +241,11 @@ on_macos_10_13_or_lower <- function() {
package_version(unname(Sys.info()["release"])) < "18.0.0"
}
+on_rosetta <- function() {
+ identical(tolower(Sys.info()[["sysname"]]), "darwin") &&
+ identical(system("sysctl -n sysctl.proc_translated", intern = TRUE), "1")
+}
+
option_use_threads <- function() {
!is_false(getOption("arrow.use_threads"))
}
diff --git a/r/R/install-arrow.R b/r/R/install-arrow.R
index 8380fa2af9..7017d4f39b 100644
--- a/r/R/install-arrow.R
+++ b/r/R/install-arrow.R
@@ -61,7 +61,6 @@ install_arrow <- function(nightly = FALSE,
verbose = Sys.getenv("ARROW_R_DEV", FALSE),
repos = getOption("repos"),
...) {
- sysname <- tolower(Sys.info()[["sysname"]])
conda <- isTRUE(grepl("conda", R.Version()$platform))
if (conda) {
@@ -80,8 +79,7 @@ install_arrow <- function(nightly = FALSE,
# On the M1, we can't use the usual autobrew, which pulls Intel
dependencies
apple_m1 <- grepl("arm-apple|aarch64.*darwin", R.Version()$platform)
# On Rosetta, we have to build without JEMALLOC, so we also can't autobrew
- rosetta <- identical(sysname, "darwin") && identical(system("sysctl -n
sysctl.proc_translated", intern = TRUE), "1")
- if (rosetta) {
+ if (on_rosetta()) {
Sys.setenv(ARROW_JEMALLOC = "OFF")
}
if (apple_m1 || rosetta) {
diff --git a/r/README.md b/r/README.md
index d343d6979c..3c1e3570ff 100644
--- a/r/README.md
+++ b/r/README.md
@@ -73,6 +73,8 @@ additional steps should be required.
There are some special cases to note:
+- On macOS, the R you use with Arrow should match the architecture of the
machine you are using. If you're using an ARM (aka M1, M2, etc.) processor use
R compiled for arm64. If you're using an Intel based mac, use R compiled for
x86. Using R and Arrow compiled for Intel based macs on an ARM based mac will
result in segfaults and crashes.
+
- On Linux the installation process can sometimes be more involved because
CRAN does not host binaries for Linux. For more information please see the
[installation guide](https://arrow.apache.org/docs/r/articles/install.html).