r-lib/backports

Install new version of backports on Mac Catalina with R 4.01

Closed this issue · 3 comments

Here's the error message

install.packages("backports")

There is a binary version available but the source version is later:
binary source needs_compilation
backports 1.1.7 1.1.8 TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘backports’

trying URL 'https://cran.rstudio.com/src/contrib/backports_1.1.8.tar.gz'
Content type 'application/x-gzip' length 18047 bytes (17 KB)

downloaded 17 KB

  • installing source package ‘backports’ ...
    ** package ‘backports’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** libs
    /usr/local/gfortran//bin/gcc -fopenmp -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/opt/gettext/include -I/usr/local/gfortran//include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -fPIC -g -O3 -Wall -pedantic -std=gnu99 -mtune=native -pipe -c dotsElt.c -o dotsElt.o
    In file included from /Library/Frameworks/R.framework/Resources/include/R.h:55,
    from dotsElt.c:1:
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:62:10: fatal error: sys/cdefs.h: No such file or directory
    #include <sys/cdefs.h>
    ^~~~~~~~~~~~~
    compilation terminated.
    make: *** [dotsElt.o] Error 1
    ERROR: compilation failed for package ‘backports’
  • removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/backports’
  • restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/backports’
    Warning in install.packages :
    installation of package ‘backports’ had non-zero exit status
mllg commented

Looks like your system is not setup properly to compile packages. If I'm not mistaken, you will get similar errors for all packages with compiled code, e.g.

install.packages("rpart", type = "source")

I had the same issue, and solved reinstalling Rtools, following the steps on:
https://cran.r-project.org/bin/windows/Rtools/

I'm working on a Mac so Rtools is not the solution. But in the meantime I solved my problem. It involved removing Makevars in the ~/.R directory (it had some incorrect entries) and cleaning up my PATH (again, some old paths that weren't needed). I am now compiling without issues.