R:在macOS 10.15上升级到R 4.0后,无法从源代码安装R软件包



我刚刚升级到R 4.0,正在尝试重新安装一些软件包。然而,我现在似乎无法从源代码进行安装。

例如,当运行install.packages("rlang")并在询问Do you want to install from sources the package which needs compilation? (Yes/no/cancel)时回答yes时,我得到以下错误消息:

In file included from capture.c:1:
/Library/Frameworks/R.framework/Resources/include/Rinternals.h:39:11: fatal error: 'stdio.h' file
not found
# include <stdio.h>
^~~~~~~~~
1 error generated.
make: *** [capture.o] Error 1
ERROR: compilation failed for package ‘rlang’

有人知道怎么解决这个问题吗?我知道我可以安装二进制版本,但如果不修复的话,这对未来的软件包安装来说可能仍然是一个令人讨厌的问题。

非常感谢!


如果有帮助,这里是sessionInfo():的输出

R version 4.0.0 (2020-04-24)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.4
Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.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.0

我也在rlangGitHub上发布了这个问题,其中一位开发人员建议进行以下修复:

  1. 创建~/.R/Makevars文件(如果尚未存在(
  2. ~/.R/Makevars中添加以下行:
CPPFLAGS += -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include

这似乎解决了我的问题。请注意,此修复程序仅适用于macOS 10.15(Catalina(

有关macOS的R工具链的更多有用信息,请点击此处:https://thecoatlessprofessor.com/programming/cpp/r-compiler-tools-for-rcpp-on-macos/

最新更新