在将我的 mac 升级到 10.12.6 (Sierra) 后运行 R 时,R 无法再加载库或访问 Internet 上的任何内容:
> install.packages("devtools")
--- Please select a CRAN mirror for use in this session ---
Warning: failed to download mirrors file (internet routines cannot be loaded); using local file '/anaconda/lib/R/doc/CRAN_mirrors.csv'
[...]
Warning: unable to access index for repository
https://cran.cnr.berkeley.edu/src/contrib:
internet routines cannot be loaded
Warning messages:
1: In download.file(url, destfile = f, quiet = TRUE) :
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: @rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
2: package ‘devtools’ is not available (for R version 3.4.1)
相似地:
> source("https://bioconductor.org/biocLite.R")
Error in file(filename, "r", encoding = encoding) :
internet routines cannot be loaded
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
unable to load shared object '/anaconda/lib/R/modules//internet.so':
dlopen(/anaconda/lib/R/modules//internet.so, 6): Library not loaded: @rpath/libssh2.1.dylib
Referenced from: /anaconda/lib/R/modules//internet.so
Reason: image not found
当我从终端运行 R 和从 RStudio 运行 R 时都会发生这种情况(尽管 RStudio 只给我错误,而不是警告,然后仍然失败)。
我发现其他人过去也有类似的问题;一种常见的解决方案是重新安装 XQuartz,我已经这样做了,但没有帮助。
另一个常见的解决方案是更新 LD_LIBRARY_PATH。但是,“libssh2.1.dylib”似乎不存在:“locate libssh2.1.dylib”不返回任何内容。我确实在 /Applications/Xcode.app/Contents/Developer/usr/lib/libssh2.dylib 中找到了 libssh2.dylib,这大概是同一件事,但我想 R 没有找到它。
有任何想法吗?谢谢!