When I try to compile R packages from source, it uses the compilers and settings defined in etc/Makeconf
within the R installation directory. How can I override these settings?
I have an ~/.R/Makevars
file (suggested e.g. here), and I included the settings I want there, but these are not being used for some reason. Why not, and how can I fix this?
I could not find the official documentation on ~/.R/Makevars
and Makeconf
—links would be welcome.
In the past, this very same setup used to work correctly for me, but recently it doesn't. I assume something must have changed in recent R versions, but I am not sure when. Were there any recent changes that could have affected this?
Motivation and context:
I am on macOS and I want to use gfortran
from MacPorts. Thus I set FC = /opt/local/bin/gfortran-mp-11
and FLIBS = -L/opt/local/lib/gcc11 -lgfortran -lquadmath -lm
in ~/.R/Makevars
. However, the system still wants to use a gfortran installation in /usr/local
, which does not exist on my machine. It clearly takes the paths and options from etc/Makeconf
. I am using the official R binaries.
It turns out that the reason why ~/.R/Makevars
was ignored on my machine when trying to build a certain package was a bug in withr
:
Installing the development version of withr
using devtools::install_github("r-lib/withr@master")
fixed the problem.