R下载总是报错nloptr,gert, Cairo, for mac
报错如下
ERROR: configuration failed for package ‘nloptr’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/nloptr’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/nloptr’
Warning in install.packages :
installation of package ‘nloptr’ had non-zero exit status
原因
Mac 电脑的中R的编译config有问题
解决
1.打开cmd,安装cmake
安装时会有java报错,但java -version 显示已安装成功
sudo apt install cmake
##结果
The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
Please visit http://www.java.com for information on installing Java.
用brew安装
##安装成功
brew install cmake
.....
cmake --version
#cmake version 3.25.1
2.返回Rstudio
install.packages("Rcpp")
install.packages("plotly")
不知道这个装了管用不管用,反正也下了
3.安装R包
install.packages("nloptr", dependencies = TRUE)
成功,R的编译问题困了好久,经常找不到原因
4. gert安装不成功
报错找不到 libgit2库
##报错
<stdin>:1:10: fatal error: 'git2.h' file not found
#include <git2.h>
在cmd中安装libgit2
brew install libgit2
5.Cairo安装不成功
在cmd中安装
brew install libxt
6.locfit 安装不成功,没有对应版本
package ‘locfit’ is not available for Bioconductor version ‘3.12’
BiocManager::available('locfit')
##不成功则用
install.packages("locfit",type="binary")
##不成功则用
install.packages("estimate", repos="http://r-forge.r-project.org", dependencies=TRUE)