Search code examples
rpackage

Failing to install (compile) minpack.lm on Mac M1


I am attempting to install the package minpack.lm on R 4.2.2, running on macOS Ventura with an M1 Pro chip. I attempted installing from source, but get the following errors during install: enter image description here

I inspected my directory and the folder /opt/homebrew/opt/gcc/lib/gcc/current/gcc/aarch-64-apple-darwin21/12 does exist.

Question: How can I fix this problem and install minpack.lm?

Thanks for helping!

Edit 1: Installing from binary does not seem possible. enter image description here

Edit 2: Installing with type = "mac.binary" succeeds, but then leads to an error when loading the package:

enter image description here


Solution

  • The easiest solution was to reinstall R using:

    brew install --cask r
    brew install --cask xquartz
    

    Then, installing minpack.lm via its binaries worked fine:

    > install.packages("minpack.lm") # works!
    

    However, installing from source would still lead to an error about gfortran missing: /opt/R/arm64/bin/gfortran: No such file or directory. The issue is related to changes to homebrew, where the gfortran recipe was integrated into gcc, causing a compilation error in new systems (since cannot find gfortran where expected). See this blog post and this other blog post for more detailed explanations.

    In order to be able to also install the package from source, an explicit installation of gfortran is necessary. For that, please refer to the instructions under "GNU Fortran compiler" in the mac.r-project.org website.

    I appreciate the help of the minpack.lm package author in finding this solution.