Mac OS make: /usr/local/gfortran: Permission denied

What is the proper set up instructions for enabling gfortran for packages? My set up is

macOS Mojave 10.14.1
/Library/Developer/CommandLineTools # xcode-select -p
XQuartz 2.7.11
Microsoft R Open Feather Spray 3.5.1
clang version 6.0.0
GNU Fortran (Homebrew GCC 8.2.0) 8.2.0 # I have 6.1 in /usr/local/gfortran

Attempting to install any package that relies on gfortran gives

make: /usr/local/gfortran: Permission denied
make: *** [eigen.o] Error 1


ls -l /usr/local/bin/gfortran

and you may see that it is a link to a directory where you don't have proper permissions.

lrwxr-xr-x  1 root  admin    32B Aug 10 18:41 /usr/local/bin/gfortran@ -> /usr/local/gfortran/bin/gfortran

or, even more simply

$ 530:  which gfortran

It may be as simple as moving /usr/local/gfortran closer to the top of $PATH. I went through something similar in August. Sorry I didn't keep notes, but I don't recall any special trauma.

This is what I get,

Tardis:~ jbsc$ ls -l /usr/local/bin/gfortran
lrwxr-xr-x  1 jbsc  admin  32 Nov 24 00:35 /usr/local/bin/gfortran -> ../Cellar/gcc/8.2.0/bin/gfortran

It seems it is a link the system gfortran or the brew llvm one. How can I change it to the 6.1 version I downloaded using the pkg from CRAN?

The best way is to edit .profile or .bash_profile to move your preferred version path to the head of the line. I'll assume, for the sake of illustration that it lives in /usr/bin.

echo $PATH

which puts /usr/bin first in line to look for gfortran or anything else

The issue is that I don't know where gfortran 6.1 gets installed. I use the pkg image and it indicates the version should be available at /usr/local/bin/gfortran but every time I check it calls the system on

Tardis:~ jbsc$ gfortran --version
GNU Fortran (Homebrew GCC 8.2.0) 8.2.0

I am not sure what path to add the to PATH...

I'm working on using a standalone gfortran installer to make sure it doesn't break anything before recommending it to you. In the meantime, is there a reason why you're using Microsoft R Open Feather Spray 3.5.1 rather than the CRAN Mac binary? Finally, what's an example of a gfortran package that throws this error?

OK, here's what I've arrived at.

  1. Uninstall the Microsoft version.
  2. Install the CRAN binrary
  3. Update XCode to 10.1, if you haven't already
  4. Install the Xcode command line tools from the terminal: xcode-select --install
  5. See the CRAN page on MAC at
  6. Follow the links to
  7. Install, reboot, check which gfortran, retry compiling R package
  8. Report back problems, successes for benefit of community

Good luck!

1 Like

Seems like the standard instructions for v3.5.1 on Mac OS work just fine, but the issue is something related to the Microsoft R Open distribution.

See Unable to install libraries on Microsoft R Open 3.5 / MacOS High Sierra / R Studio 1.1.453

1 Like

I don't know what added bells and whistles the MS version offers, but it's hard to go wrong with the official CRAN binaries.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.