Hello everyone,
I tried to install the latest R version (4.0.2) on my MacBook Pro with macOS Catalina 10.15.5, but I have an issue when installing R packages from source. I didn't have any problem before, when using R (3.6).
For example when I try to install the roxygen2 package with the command install.packages("roxygen2")
I get the following error:
There is a binary version available but the source version is later:
binary source needs_compilation
roxygen2 7.1.0 7.1.1 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
installing the source package ‘roxygen2’
trying URL 'https://cran.rstudio.com/src/contrib/roxygen2_7.1.1.tar.gz'
Content type 'application/x-gzip' length 254118 bytes (248 KB)
==================================================
downloaded 248 KB
* installing *source* package ‘roxygen2’ ...
** package ‘roxygen2’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/clang4/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include' -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/RcppCommon.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
In file included from /usr/local/clang4/bin/../include/c++/v1/cmath:305:
/usr/local/clang4/bin/../include/c++/v1/math.h:301:15: fatal error: 'math.h' file not found
#include_next <math.h>
^~~~~~~~
1 error generated.
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package ‘roxygen2’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/roxygen2’
Warning in install.packages :
installation of package ‘roxygen2’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/3p/0b9xm41j3kvb_885pst3fv580000gn/T/RtmpvHzNsT/downloaded_packages’
Another example is when I try to install the fs package:
There is a binary version available but the source version is later:
binary source needs_compilation
fs 1.4.1 1.4.2 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y
installing the source package ‘fs’
trying URL 'https://cran.rstudio.com/src/contrib/fs_1.4.2.tar.gz'
Content type 'application/x-gzip' length 819583 bytes (800 KB)
==================================================
downloaded 800 KB
* installing *source* package ‘fs’ ...
** package ‘fs’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/usr/local/clang4/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I./libuv/include -I. -pthread -I/usr/local/include -fPIC -Wall -g -O2 -c dir.cc -o dir.o
In file included from dir.cc:1:
In file included from ./getmode.h:4:
In file included from /Library/Frameworks/R.framework/Resources/include/Rinternals.h:34:
In file included from /usr/local/clang4/bin/../include/c++/v1/cstdio:100:
/usr/local/clang4/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found
#include_next <stdio.h>
^~~~~~~~~
1 error generated.
make: *** [dir.o] Error 1
ERROR: compilation failed for package ‘fs’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/fs’
Warning in install.packages :
installation of package ‘fs’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/3p/0b9xm41j3kvb_885pst3fv580000gn/T/RtmpvHzNsT/downloaded_packages’
Here are some infos regarding the R session:
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.2 tools_4.0.2
I think that the problem lies in the link between R and clang. I already tried to install and reset the Command Line Toolbox via the Mac Terminal using the commands xcode-select --install
and xcode-select --reset
, but without success.
Do you know how I can fix this issue?
Thanks in advance,
Alessandro