on a current macos system with the latest brew system (for gcc and other utilities), important packages like lmtest no longer install.
the error says the emutls_w library is not found.
Answer follows.
although the following works, too, a better solution is probably brew reinstall gcc first and see if it works.
the problem is that the current brew system seems to still use an older gcc version, that refers to itself as aarch64-apple-darwin21/ (maybe only when installed earlier). the R packages want what is relevant to the current version of macos, which is aarch64-apple-darwin22 (see uname -a).
a nasty workaround is to
$ sudo bash
# pushd /opt/homebrew/opt/gcc/lib/gcc/current/gcc/
# ln -s aarch64-apple-darwin21 aarch64-apple-darwin22
then install what you need (in another terminal), and then
# rm aarch64-apple-darwin22
aarch64-apple-darwin24 and not 22, so the actual lines of code I used were ln -s aarch64-apple-darwin24 aarch64-apple-darwin21 and rm aarch64-apple-darwin21brew reinstall gcc did not work for me. I tried brew uninstall gcc && brew install gcc, which did not solve the issue either.
I had to edit my ~/.R/Makevars file and add -L/opt/homebrew/Cellar/gcc/14.2.0_1/lib/gcc/current/gcc/aarch64-apple-darwin24/14/ to LDFLAGS.
brew --cellar prints the folder pathMakevars file with the additional LDFLAGS path worked for me too.-L/usr/local/Cellar/gcc/15.2.0/lib/gcc/current When I included more of the path it found emutls_w but could no longer find gfortran (annoying). Thanks for your help!I was able to install the required files through `macrtools`:
# install.packages("remotes")
remotes::install_github("coatless-mac/macrtools")
macrtools::gfortran_install()
This did not require me to change the `Makevars` file.
To install all tools run:
macrtools::macos_rtools_install()