Search code examples
ranacondarstudiomacos-sierraarules

R package arules installation error on macos


I'm trying to install 'arules' package from within R console with the following * setup: macOS Sierra v 10.12.6, R version 3.4.2, RStudio 1.1.383, Anaconda 5.0; anaconda client version 1.6.5, python 3.6.3

  • From within R console with the command:

    install.packages("arules")
    
  • Error output:

    install.packages("arules")
    trying URL 'https://cran.revolutionanalytics.com/src/contrib/arules_1.5-4.tar.gz'
    Content type 'application/octet-stream' length 1359205 bytes (1.3 MB)
    ==================================================
    downloaded 1.3 MB
    
    * installing *source* package ‘arules’ ...
    ** package ‘arules’ successfully unpacked and MD5 sums checked
    ** libs
    x86_64-apple-darwin13.4.0-clang -I/Users/alsabay/anaconda3/lib/R/include -DNDEBUG   -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/Users/alsabay/anaconda3/include  -DNDEBUG -DNIMAPFN -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/alsabay/anaconda3/include  -c arrayIndex.c -o arrayIndex.o
    make: x86_64-apple-darwin13.4.0-clang: No such file or directory
    make: *** [arrayIndex.o] Error 1
    ERROR: compilation failed for package ‘arules’
    * removing ‘/Users/alsabay/anaconda3/lib/R/library/arules’
    
    The downloaded source packages are in ‘/private/var/folders/lc/_068llz1667dp1m75b_js4hr09p31n/T/RtmpObrwiG/downloaded_packages’
    Updating HTML index of packages in '.Library'
    Making 'packages.html' ... done
    Warning message:
    In install.packages("arules") :
      installation of package ‘arules’ had non-zero exit status
    

I have updated xcode command line tools as well to version 9.1, and I still get the same error. I have also tried installing it from RStudio with dependencies checked and i get the same error with the added compile errors on the dependency packages. I've run out of clues here, though I know it's some kind of a clang compile error but not sure about next steps. Please help.


Solution

  • Here's how i solved this issue using suggestion above

    1. Download clang4 for macos according to the instructions on cran.r-project.org/bin/macosx/tools.

    2. Copy clang4 to /usr/local/clang4.

    3. Create Makevars file in directory ~/.R with the following environment variables.

      CC=/usr/local/clang4/bin/clang
      CXX=/usr/local/clang4/bin/clang++
      LDFLAGS=-L/usr/local/clang4/lib
      FC=/usr/local/bin/gfortran
      F77=/usr/local/bin/gfortran
      
    4. Download and install gfortran-4.2.3.pkg from cran.r-project.org/bin/macosx/tools (this has an installer).

    5. Start R console and type

      install.packages('arules')
      install.packages('arulesViz')