本楼主偶然发现本地电脑无法正常下载更新 R 包了,但是换同事电脑一试是正常的。于是我下载了最新的 R 4.2.2,直接在 R 里面选择镜像或者下载 R 包也是都不行。报的错如下,都是说无法打开链接,但实际上我用 Edge 浏览器(版本 106.0.1370.47 (正式版本) (64 位))都可以正常打开。这说明我可以正常访问那些镜像网站,也可以手动选择下载包,但是无法通过 R 下载包了。
不管选择国内哪个镜像一定报错
> chooseCRANmirror()
Warning: failed to download mirrors file (无法打开URL'https://cran.r-project.org/CRAN_mirrors.csv'); using local file 'D:/D/R/R-4.2.2/doc/CRAN_mirrors.csv'
Warning message:
In download.file(url, destfile = f, quiet = TRUE) :
URL 'https://cran.r-project.org/CRAN_mirrors.csv': Timeout of 60 seconds was reached
不管下载哪个包一定报错
> install.packages("markdown")
Warning: 无法在貯藏處https://mirrors.bfsu.edu.cn/CRAN/src/contrib中读写索引:
无法打开URL'https://mirrors.bfsu.edu.cn/CRAN/src/contrib/PACKAGES'
Warning: 无法在貯藏處https://mirrors.bfsu.edu.cn/CRAN/bin/windows/contrib/4.2中读写索引:
无法打开URL'https://mirrors.bfsu.edu.cn/CRAN/bin/windows/contrib/4.2/PACKAGES'
Warning message:
package ‘markdown’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
翻了一些别人遇到类似的问题,如https://stackoverflow.com/questions/33355444/r-when-trying-to-install-package-internetopenurl-failed还有https://stackoverflow.com/questions/25599943/unable-to-install-packages-in-latest-version-of-rstudio-and-r-version-3-1-1,里面提到设置options(download.file.method="libcurl")
或者设置取消"Tools -> Global Options -> Packages -> "Use Internet Explorer library/proxy for HTTP",试了都不行。另,可能是我本身没琢磨出来这是个什么问题,所以没有用正确的关键词搜到我想要的答案吧。