M1 Mac Dev Machine Setup - rstudio/rstudio Wiki

M1 Mac Dev Machine Setup

How to go from a clean M1 Mac to an RStudio IDE development machine. This will enable building and debugging RStudio Server and RStudio Desktop (both QtWebEngine and Electron flavors).

These steps can also be used on an Intel Mac; just leave out the parts annotated with (M1 Only).

Summary of Differences from Intel Machine Setup

If you're familiar with setting up an Intel Mac for RStudio development, here are the differences:

Preliminaries

Screenshot of Qt Online Installer

Homebrew

Clone Repo

Install dependencies

Building and running the Dev Server

RServer and RSession (native C++ components)

GWT UI (Java sources transpiled to JavaScript)

Building RStudio Desktop (QtWebEngine)

Running RStudio Desktop

Electron Desktop

The Electron desktop can be built entirely M1 native (unlike Qt desktop).

To build and execute RStudio Electron, you must have node.js and yarn installed and on the path. For this tutorial we'll install them directly via brew, but you might want to consider using the node version manager, as it will let you switch between different versions of node.

Building Electron Desktop

In developer mode, the Electron Desktop requires you have a native build of the C++ code. So, M1 on an M1 machine, Intel on an Intel machine. Thus a Qt desktop build as described above does not meet this requirement on an M1 machine.

The most direct way is:

For GWT, either use ant desktop or the results of ant or ant draft.

Running Electron desktop

Package Build

A "package build" is what is produced by the official build. On Mac, by default, it creates a DMG containing the Intel version of desktop, and both the Intel and M1 versions of the rsession binary.

To produce the Electron package:

Windows

For running Windows VMs on an M1 Mac, we recommend using the native ARM architecture for Windows. This has not officially been released yet, but Microsoft provides preview releases of Windows 11 on ARM64 here: https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64.

You can use whatever VM software you prefer/are the most comfortable with, but if you have no preference, Parallels tends to be the easiest for new users to set up.

Once you have a Windows VM, you will need to go through all the steps detailed on Installing Rstudio Dependencies - Windows.

The x86/x64 emulation done by Windows is pretty good, but in some cases you may want to install ARM64-native tools where possible.

Installing R

When installing R, there are some important things to watch out for during the installation. It is recommended to run the installation as Administrator in order to ensure your registry is appropriately updated.

  1. Change the install path. Typically, you should install R into C:\R\R-{version}
  2. Uncheck the 32-bit installation, and check the 64-bit installation to make sure you are installing the x64 version of R.
    • Note: R versions 4.0.3 through 4.1.2 do not work with Windows ARM architecture.
    • R versions 3.6.3, 4.0.0, and 4.2.0 64-bit versions have been verified to run successfully on Windows ARM.
  3. Make sure the checkbox for "Save version number in registry" is checked.
  4. [Optional] In the start menu, search for Settings > View advanced system settings > Environment variables, and edit the Path variable to point to the folder containing the R.exe executable version you wish to use.

Note that you can install multiple versions of R, but the most recently installed one will be the one available on the registry that Qt Creator will use in different builds. If you want to flip between different versions of R, you will need to take the following steps:

HKEY_LOCAL_MACHINE/
└── SOFTWARE/
    └── WOW6432Node/
        └── R-core/
            ├── R/ [Current Version: 4.2.0 Pre-release; InstallPath: C:\R\R-devel]
            │   ├── 4.2.0 Pre-release [InstallPath: C:\R\R-devel]
            │   ├── 3.6.3 [InstallPath: C:\R\R-3.6.3]
            │   └── 4.0.0 [InstallPath: C:\R\R-4.0.0]
            └── R64/ [Current Version: 4.2.0 Pre-release; InstallPath: C:\R\R-devel]
                ├── 4.2.0 Pre-release [InstallPath: C:\R\R-devel]
                ├── 3.6.3 [InstallPath: C:\R\R-3.6.3]
                └── 4.0.0 [InstallPath: C:\R\R-4.0.0]

Running RStudio Desktop on Windows