Installation problems: Compilation ERROR, function(s)/method(s) not created!

I’m having issues with my Rstan installation. When I try to run any of the test code or run the schools.stan example, I receive a similar error as shown below.

I tried to follow the instructions to uninstall, restart RStudio, and re-do the installation as on the quick setup page, but have tried multiple times and keep getting the same error.

Not sure if others have run into the same issue, but if so would be great to know how it was resolved.

Compilation ERROR, function(s)/method(s) not created!
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Warning message:In system(cmd) :  'CreateProcess' failed to run 'C:\rtools40\usr\bin\make.exe -f "C:/PROGRA~1/R/R-41~1.2/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-41~1.2/share/make/winshlib.mk" CXX='$(CXX14) $(CXX14STD)' CXXFLAGS='$(CXX14FLAGS)' CXXPICFLAGS='$(CXX14PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX14LDFLAGS)' SHLIB_LD='$(SHLIB_CXX14LD)' SHLIB="file3d281a396e84.dll" WIN=64 TCLBIN=64 OBJECTS="file3d281a396e84.o"'
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  '-E' not found

This is an issue with RTools itself, rather than Stan. To verify, try installing jsonlite from source:

install.packages("jsonlite",type="source")

There’s an open issue on the RTools github here: Problems with rtools when installing RSTAN · Issue #20 · r-windows/rtools-installer · GitHub, I’d suggest adding a comment there to indicate that it’s affecting multiple users