r - R:在 macOS 10.15 上升级到 R 4.0 后,无法从源代码安装 R 包
问题描述
我刚刚升级到 R 4.0 并试图重新安装一些软件包。但是,我现在似乎无法从源代码安装。
例如,在询问时运行install.packages("rlang")
和回答yes
时Do you want to install from sources the package which needs compilation? (Yes/no/cancel)
,我收到以下错误消息:
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
解决方案
我还在rlang
GitHub 上发布了这个问题,其中一位开发人员建议了以下修复:
- 创建
~/.R/Makevars
文件(如果还没有) - 将以下行添加到
~/.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/
推荐阅读
- php - 是否可以在 php date() 中添加自动换行
- ruby-on-rails - 将参数从视图传递到控制器
- kubernetes - Pod 没有在使用 kubespray 添加到 k8s 集群的新节点上获得计划/分配的 IP 地址
- flutter - 如何比较flutter中的时间?
- android - 重新打开应用后如何保留之前的 FCM 通知?
- spring-boot - 需要在 Spring Boot 中使用刷新令牌刷新访问令牌
- reactjs - 选中复选框时React JS防止触发onClick
- java - ObjectStorageAsyc 不等待完成
- robotframework - 如何在机器人框架中拆分字符串
- webpack - 如何动态导入名称由带有 rollupjs 的参数定义的模块?