Latest versions of MacOS have a lot of problems when it comes to installing R and making it compile packages from source smoothly. What are the steps to set up a new machine so R works smoothly on a Mac and compiles packages from source smoothly?
-
It is usually better to go one by one. What is the problem you're facing? Also have you tried homebrew? – Anuvrat Parashar Jun 08 '19 at 02:45
-
The problem was that R would not compile packages from source. Also there are multiple things that need to be installed for R to work well on a Mac. I'm sharing what worked for me in the answer below. Yes, it is better to go one by one installation of all these components below. I have not tried homebrew install of R. – Sootica Jun 08 '19 at 02:55
1 Answers
Here are the steps that led to successful installation of R on a new Mac lately, with no issues compiling from source. Please google for the latest download links the texts refer to.
Installing
X Code
from App Store. After installation, open it to accept terms; then need to install command line tools: go to terminal, type inxcode-select --install
.Install
xQuaz/X11
.Install
Java JDK
, then go to Terminal, sign in as root user, type inR CMD javareconf
so it's set up. This requires root user to be enabled so java can access and write (type in Terminal the following:dsenableroot
to enable root user). Sometimes the latest Java JDK doesn’t work (e.g., current Java JDK 12 is not supported, while version 11 is), so install the appropriate version of Java JDK again, then go to/Library/Java/JavaVirtualMachines
and remove the directory whose name matches the following format/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk
. Do not attempt to uninstall Java by removing the Java tools from /usr/bin. Once only the appropriate Java version is present in above folder, re-runR CMD javareconf
.Install
clang
: go to R page, and there is a list of r tools for Mac, pick correct version of clang for the current R version. During installation, there are instructions on creating paths, need to follow these instructions for clang to work.Install
gfortran
. The version on R page rtools does not currently work, use following fortran for Mojave: [https://github.com/fxcoudert/gfortran-for-macOS/releases]

- 111
- 2