`gfortran` installation not found
Setting up a new Mac, I ran
rig sysreqs add gfortran
producing output:
[INFO] Running `sudo` for installing gfortran. This might need your password.
Password:
[INFO] Downloading https://github.com/R-macos/gcc-darwin-arm64/releases/download/R-4.2.0-release/gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz -> /tmp/rig/gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz
[INFO] Unpacking gfortran
[INFO] Updating gfortran link to your Apple SDK
[INFO] > Updating gfortran SDK path to /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
Then, attempting to install a package with fortran code:
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source quickr.test.pkg
* installing to library ‘/Users/tomasz/Library/R/arm64/4.4/library’
* installing *source* package ‘quickr.test.pkg’ ...
** using staged installation
** libs
clang -arch arm64 -I"/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/include" -DNDEBUG -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -march=native -mtune=native -c quick_add_ab_bridge.c -o quick_add_ab_bridge.o
/opt/gfortran/bin/gfortran -arch arm64 -fPIC -Wall -g -O2 -march=native -mtune=native -c quick_add_ab_fsub.f90 -o quick_add_ab_fsub.o
using C compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.6)’
sh: /opt/gfortran/bin/gfortran: No such file or directory
using SDK: ‘MacOSX15.2.sdk’
make: /opt/gfortran/bin/gfortran: No such file or directory
make: *** [quick_add_ab_fsub.o] Error 1
ERROR: compilation failed for package ‘quickr.test.pkg’
* removing ‘/Users/tomasz/Library/R/arm64/4.4/library/quickr.test.pkg’
Exited with status 1.
It seems that the gfortran that rig installs is not automatically found by the R that rig installes.
The solution was relatively simple: install the gfortran package linked to from https://mac.r-project.org/tools (link)
I’ve just stumbled across this issue as well, is there an update?
After the installation, gfortran is available at /opt/R/arm64/gfortran/bin/gfortran as well as /opt/R/arm64/bin/gfortran (via a symlink). However, R is attempting to run a nonexistent application /opt/gfortran/bin/gfortran.
Here’s the installation:
$ rig sysreqs add gfortran
[INFO] Running `sudo` for installing gfortran. This might need your password.
Password:
[INFO] Downloading https://github.com/R-macos/gcc-darwin-arm64/releases/download/R-4.2.0-release/gfortran-12.0.1-20220312-is-darwin20-arm64.tar.xz -> /tmp/rig/gfortran-12.0.1-20220312-is-
darwin20-arm64.tar.xz
[INFO] Unpacking gfortran
[INFO] Updating gfortran link to your Apple SDK
[INFO] > Updating gfortran SDK path to /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
And here’s my attempted usage (by installing ‘igraph’):
$ Rscript -e 'pak::pak("igraph")'
✔ Loading metadata database ... done
→ Will install 1 package.
→ Will download 1 CRAN package (5.12 MB).
+ igraph 2.2.1 👷🏼♀️🔧 ⬇ (5.12 MB)
ℹ Getting 1 pkg (5.12 MB)
✔ Cached copy of igraph 2.2.1 (source) is the latest build
ℹ Building igraph 2.2.1
✖ Failed to build igraph 2.2.1 (6.7s)
Error:
! error in pak subprocess
Caused by error in `stop_task_build(state, worker)`:
! Failed to build source package igraph.
Full installation output:
* installing *source* package ‘igraph’ ...
** this is package ‘igraph’ version ‘2.2.1’
** package ‘igraph’ successfully unpacked and MD5 sums checked
staged installation is only possible with locking
** using non-staged installation
libxml2 include directories: -I/opt/local/include/libxml2
libxml2 library link flags: -L/opt/local/lib -lxml2 -L/opt/local/lib -lz -L/opt/local/lib -llzma -L/opt/local/lib -licuuc -liconv
Using vendored GLPK
** libs
Makevars:20: deps.mk: No such file or directory
using C compiler: ‘Apple clang version 17.0.0 (clang-1700.0.13.5)’
using C++ compiler: ‘Apple clang version 17.0.0 (clang-1700.0.13.5)’
using SDK: ‘MacOSX15.5.sdk’
/opt/gfortran/bin/gfortran -arch arm64 -fvisibility=hidden -fPIC -Wall -g -O2 -c vendor/arpack/dgetv0.f -o vendor/arpack/dgetv0.o make: /opt/gfortran/bin/gfortran: No such file or directory make: *** [vendor/arpack/dgetv0.o] Error 1
ERROR: compilation failed for package ‘igraph’
* removing ‘/private/var/folders/l3/j92p0xkx14v5y6dj1gt2x0r00000gn/T/Rtmp9uj55c/pkg-lib157af779a0cad/igraph
(It’s worth noting that the “Makevars:20: deps.mk: No such file or directory” error is coming from the ‘igraph’ package itself.)
R version & SDKs
_
platform aarch64-apple-darwin20
arch aarch64
os darwin20
system aarch64, darwin20
status
major 4
minor 5.1
year 2025
month 06
day 13
svn rev 88306
language R
version.string R version 4.5.1 (2025-06-13)
nickname Great Square Root
$ ls -l /Library/Developer/CommandLineTools/SDKs/
total 0
lrwxr-xr-x 1 root wheel 14 26 Jun 16:42 MacOSX.sdk -> MacOSX15.5.sdk
drwxr-xr-x 7 root wheel 224 26 Jun 16:42 MacOSX14.5.sdk
lrwxr-xr-x 1 root wheel 14 26 Jun 16:41 MacOSX14.sdk -> MacOSX14.5.sdk
drwxr-xr-x 7 root wheel 224 21 Nov 2024 MacOSX15.2.sdk
drwxr-xr-x 7 root wheel 224 5 May 2025 MacOSX15.5.sdk
lrwxr-xr-x 1 root wheel 14 26 Jun 16:41 MacOSX15.sdk -> MacOSX15.5.sdk