Error loading impute(): '/usr/lib/libgfortran.5.dylib' (no such file)
3
0
Entering edit mode
Aaron • 0
@7e4310a4
Last seen 2.8 years ago
United States

Hello, I am trying to install the impute() package to use the WGCNA package, for which it is a dependency. I am using an M1 Mac with macOS Monterrey.

Initially, I had an issue with installing the package because of an issue with gfortran that I solved by following the solution posted on this StackOverflow page: https://stackoverflow.com/questions/70638118/configuring-compilers-on-mac-m1-big-sur-monterey-for-rcpp-and-other-tools/70664229#70664229

Now, it seems like the package has been successfully installed. However, when I try to load the package using library(), it doesn't work. The error suggest that the libgfortran.5.dylib is not located where R thinks it should be /usr/lib

When I run locate libgfortran.5.dylib in the terminal, I get the following output:

/Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libgfortran.5.dylib
/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libgfortran.5.dylib
/opt/R/arm64/gfortran/lib/libgfortran.5.dylib

I have already tried adding a link to the file in the location where R is looking, but I get an "Operation Not Permitted" error, presumably because my Mac doesn't want me to edit the user library directory.

Any ideas for how to fix? Thanks.

library("impute")

# include your problematic code here with any corresponding output 
# please also include the results of running the following in an R session 

ERROR:

`Error: package or namespace load failed for ‘impute’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/impute/libs/impute.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/impute/libs/impute.so, 0x0006): Library not loaded: @rpath/libgfortran.5.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/impute/libs/impute.so
Reason: tried: '/usr/lib/libgfortran.5.dylib' (no such file)

SESSION INFO:

R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

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

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

loaded via a namespace (and not attached):
[1] BiocManager_1.30.16 compiler_4.1.2      tools_4.1.2         knitr_1.37         
[5] xfun_0.29
Install impute • 6.9k views
ADD COMMENT
1
Entering edit mode
Andrew ▴ 10
@f610cd99
Last seen 2.8 years ago
United Kingdom

No Expert here, but had this same problem and sighed when this was the only post I found and no reply.

I cheated and just loaded the library by hand. Once loaded it was fine.

BiocManager::install("genefilter")
dyn.load('/opt/R/arm64/lib/libgfortran.5.dylib')
library(genefilter)
ADD COMMENT
0
Entering edit mode

Same problem here. Loaded from finder and agreed to 'open' for numerous files. Eventually alllowed to load the library.

ADD REPLY
0
Entering edit mode
niels ▴ 10
@0e0215df
Last seen 2.0 years ago
United States

I largely followed the instructions here: https://pat-s.me/transitioning-from-x86-to-arm64-on-macos-experiences-of-an-r-user/#gfortran

to get gfortran working... I actually installed fortran from gcc: https://gcc.gnu.org/wiki/GFortranBinaries

and then followed the advice on the first page to create a Makevars (~/.R/Makevars) file with the following:

# manual gfortran install from gcc
FLIBS   =-L/usr/local/gfortran/lib
F77     = /usr/local/gfortran/bin/gfortran
FC      = /usr/local/gfortran/bin/gfortran

and from there I was able to install the bioconductor packages that were breaking on the libgfortran loading... (I had to create the .R directory in my user location and create the Makevars file but after restarting my R instance it worked)...

ADD COMMENT
0
Entering edit mode
yuzhijian • 0
@de2a7f50
Last seen 19 months ago
United States
  1. locate the the file with: locate libgfortran.5.dylib , assume we got the path '/opt/R/arm64/gfortran/lib/libgfortran.5.dylib'

  2. find the address the package used to load the file 'libgfortran.5.dylib', in this case was '/usr/lib/libgfortran.5.dylib'

  3. symbollically link the actual path of libgfortran.5.dylib file to the address it tried to use for this file while loading the library: ln -s /opt/R/arm64/gfortran/lib/libgfortran.5.dylib /usr/lib/libgfortran.5.dylib

ADD COMMENT

Login before adding your answer.

Traffic: 430 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6