为什么Rstudio库由于libgfortran dylib而失败,但在base R中工作

fcipmucu  于 2023-05-20  发布在  其他
关注(0)|答案(1)|浏览(132)

问题

使用Rstudio,我使用BiocManager::install("edgeR")安装了edgeR,运行良好。当运行library(edgeR)时,我得到一个涉及libgfortran.5.dylib的错误:

Loading required package: limma
Error: package or namespace load failed for ‘edgeR’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Users/sbouhad2/Library/R/arm64/4.3/library/edgeR/libs/edgeR.so':
  dlopen(/Users/sbouhad2/Library/R/arm64/4.3/library/edgeR/libs/edgeR.so, 0x0006): Library not loaded: /opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0/libgfortran.5.dylib
  Referenced from: <7A0E0743-72B0-3B24-A4BB-8E34A69B6095> /Users/sbouhad2/Library/R/arm64/4.3/library/edgeR/libs/edgeR.so
  Reason: tried: '/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0/libgfortran.5.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0/libgfortran.5.dylib' (no such file), '/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0/libgfortran.5.dylib' (no such file), '/usr/local/lib/libgfortran.5.dylib' (no such file), '/usr/lib/libgfortran.5.dylib' (no such file, not in dyld cache)

当我在默认的MacOS应用程序或Rstudio中打开一个终端,然后运行R,然后运行library(edgeR),一切都很顺利,我可以运行包中的函数。我不知道该去哪里找,也不知道该怎么解决。我也不熟悉W.R.T.的技术细节。x86和arm 64。

会话信息

对于Rstudio,在运行失败的库命令之后

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Amsterdam
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods  
[7] base     

other attached packages:
[1] limma_3.55.7

loaded via a namespace (and not attached):
[1] compiler_4.3.0  tools_4.3.0     rstudioapi_0.14 Rcpp_1.0.10    
[5] grid_4.3.0      locfit_1.5-9.7  lattice_0.21-8

对于基R,在使用终端运行工作库命令之后

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] C/UTF-8/C/C/C/C

time zone: Europe/Amsterdam
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] edgeR_3.41.8 limma_3.55.7

loaded via a namespace (and not attached):
[1] compiler_4.3.0 Rcpp_1.0.10    grid_4.3.0     locfit_1.5-9.7 lattice_0.21-8

我看不出有什么不同,除了可能BLAS有不同的路径。

相关(?)背景信息

我使用(arch -arm 64)homebrew安装了gcc和gfortran,以便在MacOS上编译Rcpp包。经过长时间的搜索,我发现我需要创建~/.R/Makevars,它现在包括:

CC=gcc-13
CXX=g++-13
FLIBS   =-L/usr/local/gfortran/lib
F77     = /usr/local/gfortran/bin/gfortran
FC      = /usr/local/gfortran/bin/gfortran

通过这个修改,我可以构建Rcpp包。从那时起,edgeR无法在Rstudio中加载。
我尝试了dyn.load的一些路径,比如dyn.load("/opt/gfortran/lib/gcc/aarch64-apple-darwin20.0/12.2.0/libgfortran.5.dylib")。这在R工作室和R基地都行不通。
此外,基于Rcpp的library可以工作,我可以在R和Rstudio中执行代码。
我不知道我能做什么。

wz3gfoph

wz3gfoph1#

在@user2554330和其他人的评论的指导下,我从https://mac.r-project.org/tools/安装了gfortran。重启RStudio后,library(edgeR)可以正常工作!

相关问题