Build tools not working despite what devtools::has_devel() says

I somehow got myself into a situation where I can’t install many packages from source. devtools::has_devel() says “Your system is ready to build packages!”, but install.packages("lme4", type = "source"), for example, errors:

make: *** [external.o] Error 1
ERROR: compilation failed for package ‘lme4’

I suspect it is due to Rcpp. When installing that from source I get:

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [api.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/Rcpp’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/Rcpp’
Warning in install.packages :
  installation of package ‘Rcpp’ had non-zero exit status

Any advice on how to troubleshoot this? Or why devtools is lying to me?

R version: 4.2.0
OS: macOS 12.6

I followed the tutorial here: R Compiler Tools for Rcpp on macOS | The Coatless Professor but got the common error listed at the end (with no solution):

COMMON ERRORS

The following are debugged errors that you may run into.

clang: warning: argument unused during compilation: '-fopenmp'
fatal error: 'omp.h' file not found

Unfortunately, with R 4.0.0 the CRAN distributed version of R loses the ability to use OpenMP without a custom setup.

This is almost exactly my issue, but I followed all the suggestions and still can’t install Rcpp from source.

Solved! This was the comment that helped: Rcpp broken by Mac OS Big Sur and Xcode 12.5 · Issue #1160 · RcppCore/Rcpp · GitHub

I think I had installed some compilers with homebrew and they were conflicting with Xcode or something. I deleted the usr/local/include directory (which is apparently safe, but like, do your own research please) and now I can install packages from source.

1 Like