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
Try
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
/usr/local/bin/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
/usr/bin:/usr/local/ActiveGo-1.8.3/bin:/Users/rc/go/bin:/usr/local/lib://Users/rc/go/bin:/usr/local/bin:/usr/local/mysql/bin::/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Users/rc/bin
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? The Comprehensive R Archive Network Finally, what's an example of a gfortran package that throws this error?
OK, here's what I've arrived at.
- Uninstall the Microsoft version.
- Install the CRAN binrary
- Update XCode to 10.1, if you haven't already
- Install the Xcode command line tools from the terminal: xcode-select --install
- See the CRAN page on MAC at https://goo.gl/KPGTUJ
- Follow the links to https://git.io/fp0y6
- Install, reboot, check which gfortran, retry compiling R package
- Report back problems, successes for benefit of community
Good luck!
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
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.