R has been installing packages just fine, but suddenly – I can\'t think of anything relevant that I modified or uninstalled –
it can\'t find gcc when I run R CMD chec
R uses a BINPREF variable to locate executables:
the location of the gcc executable is given by CC = $(BINPREF)gcc $(M_ARCH)
In my case, BINPREF was being set by C:/Users/MYUSERNAME/Documents/.R/Makevars. Deleting the contents of this file removed the incorrect location.
It is also worth checking the file $RPATH/etc/i386/Makeconf, which will be re-created with each new installation of R. Note the line
BINPREF ?= c:/Rtools/mingw_32/bin/, which (via the ?= operator) will set the value of BINPREF if it is not already set, as it was in the Makevars file mentioned above.