Update on R/RStudio support for Apple Silicon Macs?

Hi All,

I recently bought an MacBook Pro with an Apple Silicon processor to do some work on COVID analytics. I've been using the EpiNow2 package to calculate the transmission rate (Rt) for COVID. This package uses the Markov Chain Monte Carlo (MCMC) method to estimate Rt, which is highly processor intensive.

I was surprised to find that it runs more slowly on my new Macbook than it does on my 2019 27" iMac. The iMac does have more RAM--40GB--than my Macbook which has 16GB, but the data file being analysed has fewer than 300 rows of input data.

My guess is that this is in part because R is running through Rosetta 2. I saw a blog by Tomas Kalibera and Simon Urbanek published in November about this, and wanted to see if there might be any updates?

It looks like work is underway on making a version of R itself for Apple Silicon which is good news!

Thanks in advance for any updates anyone might have!

If you're willing to use nightly builds, there is indeed a version of R built for Apple M1 chips now. You can get it here:

However, please note that it does not work with RStudio, which does not have an Apple Silicon build yet. Track this issue for progress reports:

1 Like

That is fantastic news--thank you!

I'd love to try out the development version of R--is it possible to set it up as a separate instance to my 'normal' R that I use with RStudio?

Hi, I've tried to download the latest arm build of R and that worked using tar as indicated on the page. Unfortunately, the link to the GUI from the R for macOS Developers page didn't work (invalid link):
https://mac.r-project.org/www/R-mac-dev/el-capitan/R-3.6-branch/R-GUI-7939-3.6-el-capitan-Release.dmg

I tried to use my existing R GUI console--using the RSwitch app to confirm that the library is pointing to the development arm64 version--and it crashes when it tries to open.

I can access the arm64 version of R using the command line in Terminal, however.

Is this a known issue (given that this is a development build), or should the R GUI work?

Thanks in advance for any thoughts you might have!

Tony

Update: We now have support for Apple Silicon (aarch64) versions of R in the RStudio daily builds. If you have one of the new M1 machines, we'd love to get your feedback on it.

Hi Jonathan. I tried installing the new RStudio but R crashed upon loading. I used RSwitch to go between my stable version (v4.0.3) and my development version of R (v4.1.0). This is the same approach I take with the stable version of RStudio (which runs R v4.0.3, but clearly not v4.1-arm64--though the latest dev version of R GUI does).

When I select R v4.0.3 in RSwitch:

Process Output: The R session process exited with code 1. (No errors or output appear)

04 Mar 2021 22:17:34 [rsession-me] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200
04 Mar 2021 22:18:45 [rsession-me] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200
04 Mar 2021 22:58:27 [rsession-me] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200

When I choose R v4.1-arm64 (v4.1.0), I get the following messages:

The R session process exited with code 6 .

ERRORS

dyld: could not load inserted library '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' because no suitable image found. Did find: /Library/Frameworks/R.framework/Resources/lib/libR.dylib: mach-o, but wrong architecture /Library/Frameworks/R.framework/Resources/lib/libR.dylib: stat() failed with errno=1

04 Mar 2021 22:17:34 [rsession-me] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200
04 Mar 2021 22:18:45 [rsession-me] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200
04 Mar 2021 22:58:27 [rsession-me] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200

I installed this by dragging the RStudio file into my Applications folder. Was this the right approach, or was there something elseI was supposed to do? (If so, could you point me toward a guide that I can follow?).

Thanks again for putting this version together! I look forward to trying it soon!

Thank for the error, that's very helpful! Can you share the output of these two commands on your system (run in Terminal)?

/usr/bin/uname -m

/usr/bin/lipo -archs /Library/Frameworks/R.framework/Resources/lib/libR.dylib

I tried to test the new daily build and had a failure to start. This occurred with the most recent beta version of R for apple silicon.
The R session failed to start.

ERROR MESSAGE

[No error available]

PROCESS OUTPUT

The R session process exited with code 1 .

ERRORS

[No errors emitted]

OUTPUT

[No output emitted]``Preformatted text

05 Mar 2021 20:44:00 [rsession-raf] ERROR generic error 8 (Exec format error) [r-home: /Library/Frameworks/R.framework/Resources, r-archs: , rsession-archs: ]; OCCURRED AT rstudio::core::Error rstudio::r::session::(anonymous namespace)::validateCompatible(const std::string &) src/cpp/r/session/RSession.cpp:270; LOGGED FROM: int main(int, char *const *) src/cpp/session/SessionMain.cpp:2200

Hi there,
I hope this feedback will help!

R version: R-devel, 4.1.0
Platform: aarch64-apple-darwin20.0 (64-bit)

Error Starting R

The R session failed to start.

ERROR MESSAGE

[No error available]

PROCESS OUTPUT

The R session process exited with code 6 .

ERRORS

dyld: could not load inserted library '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' because no suitable image found. Did find: /Library/Frameworks/R.framework/Resources/lib/libR.dylib: mach-o, but wrong architecture /Library/Frameworks/R.framework/Resources/lib/libR.dylib: stat() failed with errno=1

OUTPUT

[No output emitted]

RECENT LOG

Log File [No logs available]

NEXT STEPS

R can fail to start up for many reasons. The following may help you resolve the problem:

  • Investigate any errors above.
  • Make sure that R starts up correctly outside RStudio (using RGui, R.app, or R in a terminal).
  • Fully uninstall all versions of R from your machine, and reinstall the version you wish to use with RStudio.
  • Remove startup customizations such as an .Rprofile file, if present.

Further troubleshooting help can be found on our website:

Troubleshooting RStudio Startup

Thank you!

I'm also having the same issue where attempting to start RStudio with R 4.1.0 for arm64 on my M1 Mac gives the error:

The R session process exited with code **6** .

### ERRORS

`dyld: could not load inserted library '/Library/Frameworks/R.framework/Resources/lib/libR.dylib' because no suitable image found. Did find:
/Library/Frameworks/R.framework/Resources/lib/libR.dylib: mach-o, but wrong architecture
/Library/Frameworks/R.framework/Resources/lib/libR.dylib: stat() failed with errno=1`

Running the terminal commands outputs arm64 for both of them. Hope that helps!