Can't get a functioning install with stan 2.21.0 on windows 10 and R v4.0.2 -demo can't find rtools - solved!

I 'm struggling to get Stan to run on my computer at the moment

I’ve removed the rstan package and installed as per
I’ve installed rtools40. When running rstan::stan_demo(1), I get the following error message:
Error in compileCode(f, code, language = language, verbose = verbose) :
sh: C:/Rtools/mingw_64/bin/g++: No such file or directorymake: *** [C:/PROGRA~1/R/R-40~1.2/etc/x64/Makeconf:229: file130c67f5cc3.o] Error 127
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
‘C:/rtools40/usr/mingw_/bin/g++’ not found
Error in sink(type = “output”) : invalid connection

I had some issues with having remains of the previous version of rtools in my path, but cleaned this up, before reinstalling, and still have the above error. I cant find the paths in the above complaints when running Sys.getenv()[‘PATH’] either. Here’s the output

PATH                           C:\rtools40\usr\bin;C:\Program
                               Files\R\R-4.0.2\bin\x64;C:\Program Files (x86)\Intel\iCLS
                               Client;C:\Program Files\Intel\iCLS
                               Files (x86)\CodeSynthesis XSD 4.0\bin;C:\Program Files
                               (x86)\CodeSynthesis XSD
                               Files\R\R-3.2.1\bin;C:\Program Files\MiKTeX
                               2.9\miktex\bin\x64;C:\Program Files (x86)\Windows
                               Kits\10\Windows Performance Toolkit;C:\Program Files
                               (x86)\Microsoft Visual Studio 14.0\Common7\IDE;C:\Program
                               Files (x86)\Microsoft Visual Studio 14.0\VC\bin;C:\Program
                               Files\Microsoft SQL Server\110\Tools\Binn;C:\Program Files
                               Files\doxygen\bin;C:\Program Files\Git\cmd;C:\Program Files
                               (x86)\MiKTeX 2.9\miktex\bin;C:\Program
                               Files\Mercurial;C:\Program Files\TortoiseSVN\bin;C:\Program
                               Files\gs\gs9.21\bin;C:\Program Files (x86)\Pandoc;C:\Program
                               Files\Microsoft SQL
                               Files (x86)\GitExtensions;C:\Program Files
                               (x86)\Intel\Intel(R) Management Engine
                               Components\DAL;C:\Program Files\Intel\Intel(R) Management
                               Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R)
                               Management Engine Components\IPT;C:\Program
                               Files\Intel\Intel(R) Management Engine

I’m now at a loss - any suggestions?

Just found this v. similar issue: Problems getting Stan to run after upgrading to R 4.0.2

From that thread, I get the following when checking BINPREF,, and Renviron:

[1] ""
> readLines("~/.R/")
[1] "CXX14FLAGS += -O3 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2"
> readLines("~/.Renviron")
[1] "PATH=\"${RTOOLS40_HOME}\\usr\\bin;${PATH}\""

Finally, as adviced in the thread, I looked and found an old .Rprofile file where the rtools references were, and after removing it (physically deleting it), it worked! Quest success - sorry for adding a new thread here.


Glad you got it working!

No worries, this is our fault. The rstan installation instructions for R 4.x don’t properly account for the settings that were recommended when installing rstan with R 3.x. Glad it’s working for you now!