0

I recently updated my MacOS to version 12.5 and since then I have been unable to install certain packages in R.

For example, I am now trying to install the forecast package in R. When I try to install the package, I get the following error.

ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin18/8.2.0'
ld: warning: dylib (/usr/local/gfortran/lib/libgfortran.dylib) was built for newer macOS version (12.3) than being linked (10.13)
ld: warning: dylib (/usr/local/gfortran/lib/libquadmath.dylib) was built for newer macOS version (12.3) than being linked (10.13)

This appears to be a general problem when compiling certain packages, as I discovered after these same errors arose when I ran the "helloworld.cpp" test described here.

Based on the posts I've read (particularly this one and this one), it appears that other people have experienced similar problems and one solution is to change the compile states in ~/.R/Makevars.

I searched for ~/.R/Makevars but I was not able to find an existing file; so I tried creating a new Document file called "Makevars" in the .r folder and adding the following text to the document:

VER=-11.3.0
CC=gcc$(VER)
CXX=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/11.3.0_2/lib/gcc/11

When I tried installing the forecast package again, I received a new error:

/bin/sh: gcc-11.3.0: command not found
make: *** [etscalc.o] Error 127
ERROR: compilation failed for package ‘forecast’

How can I fix this problem and install packages again? I would appreciate any help, since I've really been struggling with this.

As background, I have gcc installed (version 11.3.0) and Xcode command line tools installed.

---------------- Update ----------------

I tried the solution proposed here, specifically:

  1. I ran ln -sf /usr/local/bin/gcc-11 /usr/local/bin/gcc in the terminal
  2. I then changed the Makevars file to
VER=-11
CC=gcc$(VER)
CXX=g++$(VER)
CXX11=g++$(VER)
CXX14=g++$(VER)
CXX17=g++$(VER)
CFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
CXXFLAGS=-mtune=native -g -O2 -Wall -pedantic -Wconversion
FLIBS=-L/usr/local/Cellar/gcc/11.3.0_2/lib/gcc/11

However, I still ran into a new error (one I can't even begin to understand) that prevented the package from loading properly.

** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
sh: line 1: 16759 Segmentation fault: 11  R_TESTS= '/Library/Frameworks/R.framework/Resources/bin/R' --no-save --no-restore --no-echo 2>&1 < '/var/folders/vw/t_hc3fcn2y5d975y2c4pvc2w0000gn/T//RtmpbcA9DF/file412625285e87'

 *** caught segfault ***
address 0x18, cause 'memory not mapped'

Here is the session info

R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.5

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

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
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] compiler_4.2.1           tools_4.2.1              RcppArmadillo_0.11.2.0.0 Rcpp_1.0.9   
  • Welcome to SO. I try to run `brew upgrade` in terminal and restart after any OS updates with mac, sometimes doing that can fix issues with all the libraries R has to interact with. – Michael Roswell Jul 26 '22 at 15:23

1 Answers1

0

What finally worked for me was removing all R packages and then installing the forecast package.

I used the answer here