2

I am trying to load the gmm package on RStudio. I am having similar problems as GMM package installation failed in R but I couldn't find adequate solutions. The original error I got was

> library(gmm)
Error: package or namespace load failed for ‘gmm’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/gmm/libs/gmm.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/gmm/libs/gmm.so, 0x0006): Library not loaded: /opt/R/arm64/gfortran/lib/libgomp.1.dylib
  Referenced from: <47242657-5A5D-3982-936B-398527D642B4> /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/gmm/libs/gmm.so
  Reason: tried: '/opt/R/arm64/gfortran/lib/libgomp.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/R/arm64/gfortran/lib/libgomp.1.dylib' (no such file), '/opt/R/arm64/gfortran/lib/libgomp.1.dylib' (no such file), '/usr/local/lib/libgomp.1.dylib' (no such file), '/usr/lib/libgomp.1.dylib' (no such file, not in dyld cache)

(I have gcc installed via Homebrew)

I tried the solution on Installing gfortran on MacBook with Apple M1 chip for use in R where I created a makevar file and added the path for the gfortran binary file. I still get the same error after editing the makevar file. I read somewhere to do install.packages("gmm", type="source") instead of install.packages("gmm"). It installed with some warnings:

> install.packages("gmm", type="source")
trying URL 'https://cran.rstudio.com/src/contrib/gmm_1.7.tar.gz'
Content type 'application/x-gzip' length 1062903 bytes (1.0 MB)
==================================================
downloaded 1.0 MB

* installing *source* package ‘gmm’ ...
** package ‘gmm’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/opt/homebrew/Cellar/gcc/12.2.0/bin/gfortran-12 -fno-optimize-sibling-calls  -fPIC  -Wall -g -O2  -c lambda_met.f -o lambda_met.o
clang -arch arm64 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/opt/R/arm64/include   -fPIC  -falign-functions=64 -Wall -g -O2  -c src.c -o src.o
clang -arch arm64 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o gmm.so lambda_met.o src.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/12 -lgomp -L/opt/homebrew/Cellar/gcc/12.2.0/lib/gcc/12 -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: -undefined dynamic_lookup may not work with chained fixups
ld: warning: could not create compact unwind for _getpt_: register 22 saved somewhere other than in frame
ld: warning: could not create compact unwind for _ols_: registers 27 and 28 not saved contiguously in frame
ld: warning: could not create compact unwind for _lamcue_: registers 27 and 28 not saved contiguously in frame
ld: warning: could not create compact unwind for _prep_: registers 27 and 28 not saved contiguously in frame
ld: warning: could not create compact unwind for _wu_: registers 74 and 75 not saved contiguously in frame
ld: warning: could not create compact unwind for _lamcuep_: registers 27 and 28 not saved contiguously in frame
installing to /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/00LOCK-gmm/00new/gmm/libs
** R
** data
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (gmm)

The downloaded source packages are in
    ‘/private/var/folders/82/mcr3vdtj7kg2_7lr7tq4vk6m0000gn/T/Rtmpe6Btiy/downloaded_packages’

And now it returns a different error:

Error: package or namespace load failed for ‘gmm’ in get(Info[i, 1], envir = env):
 lazy-load database '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library/gmm/R/gmm.rdb' is corrupt
In addition: Warning message:
In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

How do I get gmm to load correctly?

edit- below is the sessionInfo()

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-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     

other attached packages:
[1] sandwich_3.0-2

loaded via a namespace (and not attached):
[1] zoo_1.8-11      compiler_4.2.2  tools_4.2.2     rstudioapi_0.14 grid_4.2.2     
[6] lattice_0.20-45
khl
  • 21
  • 4

0 Answers0