Search code examples
rmacoshomebrewmacos-sierraosx-elcapitan

Can homebrew R and "standard" R for MacOS from CRAN coexist?


I am running R 3.6.1 on a Mac Mini running Sierra and a MacBook Pro running El Capitan. I normally get all the R packages that I need from CRAN or github and use them without issues, but I am trying to install and use an R package (NicheMapR) that requires a fortran compiler and this is giving me issues. Even after installing gfortran, the R package still does not work (the fortran code seems to be compiled but the package installation fails). The package developer suggested that installing R via homebrew might solve the problem. On the contrary, my hunch is that it would lead to a world of pain, to quote Walter from the Big Lebowski. My questions are:

  1. What is the advantage of a homebrew version of R for MacOSX over the "regular" version installed from CRAN?
  2. Can the two versions coexist?
  3. Is the homebrew version going to affect the regular one?
  4. Finally: is homebrew going to help or will it simply open a whole new can of worms?

    Many thanks in advance.


Solution

  • Yes, installing from homebrew is a recipe for pain. It's specifically recommended against by the official CRAN binary maintainer see his remarks from March 2016 on r-sig-mac.

    Regarding your questions, this can be summarized as:

    1. What is the advantage of a homebrew version of R for MacOSX over the "regular" version installed from CRAN?

    Positives: Select your own BLAS and easily work with geospatial tools.

    Downsides: Always needing to compile each R package.

    1. Can the two versions coexist?

    Yes. The homebrew version installs into a different directory. But, watch out for library collision (see next question). However, you will have to deal with symbolic linking regarding what version of R is accessible from the console and you will also need to look into using RSwitch to switch between R versions.

    1. Is the homebrew version going to affect the regular one?
    • Yes, if the library paths overlap. There will be problems regarding package installation and loading. Make sure to setup different library paths. To do so, please look at the .libPaths() documentation.
    1. Finally: is homebrew going to help or will it simply open a whole new can of worms?

    Yes and no. Unless you know what you're doing, opt for the CRAN version of R and its assorted goodies.