Skip to content
Scripts to build the Rtools-esq installer for the macOS R toolchain
Shell Rich Text Format
Branch: master
Clone or download
coatless Configuration file fixes (#29)
* Ensure existing file has owner permissions set. Close #28

* Emphasize that a backup for both configuration files is made (Close #27)

* Bump installer version

* Add release notes
Latest commit 11c446a Dec 4, 2019

Installer Package for macOS R toolchain License

The repository contains the scripts used to create an installer package (.pkg) that contains binaries used to create the CRAN official macOS R binary. Specifically, the installer will try to download and install:

Aftwards, it will attempt to configure the necessary ~/.R/Makevars and ~/.Renviron files. If either file is pre-existing, then a backup will be made prior to setting up the new versions.

For those interested, the installer can be obtained on either the project's release page or through The pre-built binaries this installer encloses can be found at,, and

Note The installer package was developed by James Joseph Balamuta and has no connection with the R project’s macOS CRAN maintainers. Financial support was provided to sign the installer by Professor Timothy Bates of the University of Edinburgh.

How do I use the installer?

  1. Download it from the project's release page or through
  2. Open the installer by either double click or right clicking to bring up menu and selecting "Open".
  3. From here, navigate through it like a normal macOS installer.

That's it.

Once installed, you can start using compiled code in R like normal with the added benefit of OpenMP.

If you want to see behind the curtain, continue reading...

What does the installer do?

The macOS R toolchain installer performs four actions that require the user's password to accomplish. These actions are:

  1. download and install XCode CLI via secure Apple product update
  2. download, verify, and install the clang7 pre-made binary files into the /usr/local/clang7 directory
  3. download, verify, and install gfortran6.1
  4. establish the proper header files in CFLAGS, CPPFLAGS, and CXXFLAGS in the ~/.R/Makevars file
  5. add to the PATH variable where the clang7 binary is by using ~/.Renviron

Note: The installer will replace existing ~/.R/Makevars and ~/.Renviron files. The existing files will be copied to a backup file, e.g. ~/.R/Makevars.bck and ~/.Renvion.bck. Re-running the installer will result in the old backup files being wiped.

Verify steps are conducted using embedded md5 hashes of the files. If the hash is not identical to what was embedded, the installer will exit. For details as to how this was implemented please see Issue 8: Verify pkg hash and the Pull Request 10: Feature Pkg Hash Verification.

Verify the Installer

Thanks to the financial support provided by Professor Timothy Bates of the University of Edinburgh to join the Apple Developer program. The installer is now signed using developer credentials.

As a result, the installer should have a "lock" icon in the upper right corner:

Signed Installer Lock Icon

Clicking the lock icon will reveal the signed developer certificate:

Signed Developer Certificate

With this being said, the code used to generate the installer has been made publically available under an open source license (GPL >= 2).

Overview of Files

Below is an abridged version of the actions of each file provided.

  • scripts/postinstall
    • Downloads and Installs Xcode CLI, clang7, and gfortran6.1
    • Create the ~/.R/Makevars file with the necessary implicit variables to compile using the new header location.
      • CFLAGS, CPPFLAGS, CXXFLAGS for clang7
    • Make the ~/.Renviron file with a modified PATH variable to the location of clang7.
    • Note: Pre-existing ~/.R/Makevars and ~/.Renviron files will be backed up prior to being overridden.
    • Create the installer package R binary installer .pkg
      • Builds the package from the extracted tar using pkgbuild
      • Analyzing the package using productbuild to create a distribution.xml
      • Inserts customizations into the distribution.xml (title, background, ...)
      • Calls productbuild to rebuild the package.
  • distribution.xml
    • Customization options (e.g. title, background) of installer built by analyzing a temporary .pkg
  • build_files/Rlogo.png
    • R logo
  • build_files/LICENSE.rtf
    • License of the Xcode CLI, LLVM installer, and gfortran
  • build_files/WELCOME_DISPLAY.rtf
    • Text displayed on welcome screen


GPL (>= 2)

You can’t perform that action at this time.