安装R包climateR、terra及RNetCDF时遇到仓库索引访问失败与编译依赖错误的求助
大家好,我在尝试从GitHub安装climateR包时碰到了一堆问题,折腾了好一阵都没搞定,想请教下各位有没有解决思路:
一、安装climateR时的依赖编译问题
我最初用这条命令安装climateR:
devtools::install_github("mikejohnson51/climateR")
执行后先弹出了仓库访问警告,还提示需要编译源包:
Warning: unable to access index for repository https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1:
cannot open URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/PACKAGES'
Packages which are only available in source form, and may need compilation of C/C++/Fortran:
‘RNetCDF’ ‘terra’
"Do you want to attempt to install these from sources?
(Yes/no/cancel)"
我选择输入YES继续,但下载到一半就报错了:
configure: error: netcdf.h was not compiled - defining CPPFLAGS may help ERROR: configuration failed for package ‘RNetCDF’ Dependencies ‘ncmeta’, ‘RNetCDF’ are not available for package ‘climateR’
后来我按照网上的建议,用Homebrew在终端安装了netcdf和gdal,但重新尝试后还是出现一模一样的错误。
二、单独安装terra或RNetCDF时的问题
想着先把依赖包单独装好,结果尝试安装terra时也出问题:
install.packages("terra")
同样先弹出仓库访问警告:
Warning in install.packages :
unable to access index for repository https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.1:
cannot open URL 'https://cloud.r-project.org/bin/macosx/big-sur-arm64/contrib/4.1/PACKAGES'
Package which is only available in source form, and may need compilation of C/C++/Fortran:
‘terra’
Do you want to attempt to install these from sources? (Yes/no/cancel)
当时我误输入了options(repos = "https://cran.rstudio.com"),直接触发了新的错误:
Error in install.packages : Unrecognized response “options(repos = "https://cran.rstudio.com")”
另外我特意在浏览器里打开那个报错的URL,页面显示“The requested URL /bin/macosx/big-sur-arm64/contrib/4.1/PACKAGES was not found on this server.”,但我的网络连接是稳定的,应该不是网络的问题。
有没有朋友碰到过类似的情况?求指点怎么解决这些问题,谢谢!
备注:内容来源于stack exchange,提问作者noricia

