install.pa" /> install.pa" /> install.pa"/>

Unable to install lmtest package in r

36 views Asked by At

I have troubles installing the package "lmtest" in r (which I in fact need to install "SetMethods" but I boiled it down to this problem):

> install.packages("lmtest")
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5:
  cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/PACKAGES'
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘lmtest’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘lmtest’

trying URL 'https://cran.rstudio.com/src/contrib/lmtest_0.9-40.tar.gz'
Content type 'application/x-gzip' length 230313 bytes (224 KB)
==================================================
downloaded 224 KB

* installing *source* package ‘lmtest’ ...
** package ‘lmtest’ successfully unpacked and MD5 sums checked
** libs
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I/usr/local/include   -fPIC  -Wall -g -O2  -c init.c -o init.o
gfortran   -fPIC  -g -O2  -c pan.f -o pan.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lmtest.so init.o pan.o -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: warning: directory not found for option '-L/usr/local/bin/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lmtest.so] Error 1
ERROR: compilation failed for package ‘lmtest’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/lmtest’
Warning in install.packages :
  installation of package ‘lmtest’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/hg/368hjqg13yqg8pmf4c10kryh0000gn/T/RtmpnjjjTR/downloaded_packages’

I think r has a problem finding the library for -lgfortran.

So, I have downloaded gfortran using Homebrew on my Mac. This is now the path to gfortran given by my terminal.

Cs-MacBook-Pro:~ ch$ which gfortran
/usr/local/bin/gfortran

Recommended by ChatGPT, I tried setting the path to gfortran in r, as r could not find the library of "-lgfortrane" before:

Sys.setenv(LIBRARY_PATH = "/usr/local/bin/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0:/usr/local/bin/gfortran/lib",
            DYLD_FALLBACK_LIBRARY_PATH = "/usr/local/bin/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0:/usr/local/bin/gfortran/lib")
 
install.packages("lmtest", type="source")

However, that resulted in the same error code as above, the most relevant lines being (I assume):

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
ld: warning: directory not found for option '-L/usr/local/bin/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
ld: warning: directory not found for option '-L/usr/local/bin/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lmtest.so] Error 1
ERROR: compilation failed for package ‘lmtest’

Any help greatly appreciated.

0

There are 0 answers