Brms compiling error - no such file or directory, invalid connection

Operating System: Windows 10
brms Version: 2.8.0
R version: 3.5.3, installed under C:\Program Files\R
Rtools 3.5 is installed under C:\Rtools

I’m getting this error when compiling a model (that works on other computers):

Compiling the C++ model
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! file2b83e9c5ba8.cpp:8:39: fatal error: stan/model/model_header.hpp: No such file or directory
#include <stan/model/model_header.hpp>
compilation terminated.
make: *** [C:/PROGRA~1/R/R-35~1.3/etc/x64/Makeconf:215: file2b83e9c5ba8.o] Error 1
In addition: Warning message:
In system(cmd, intern = !verbose) :
running command ‘C:/PROGRA~1/R/R-35~1.3/bin/x64/R CMD SHLIB file2b83e9c5ba8.cpp 2> file2b83e9c5ba8.cpp.err.txt’ had status 1
Error in sink(type = “output”) : invalid connection

Any ideas how to fix it?


It can’t find StanHeaders. I would try


in a clean R session.

I should have mentioned I have tried this before and it does not help.
It installed the package in a different place to where brms installed itself though, which could be my problem. I’ll try setting the library path to match where brms was installed and reinstalling StanHeaders.

This does not work. Every time I try to set the path to install to I get an error that says it is not writable.

You may have to alter the order of


to get everything to find everything else if you installed packages in a bunch of different places.

Ok thanks. The only thing I have installed though is brms, and then StanHeaders because brms didn’t work. So should make it easier I suppose.

I’ve installed everything into the same place and it still comes up with the same error.

The fourth person I spoke to in IT managed to fix it. It was a permissions error to do with security defaults in windows 10 for computer on a network. The solution was to specify to install into Program files rather than the default path on the network, and to set RStudio to always run as admin so that it can write into Program files.

OK. Glad you got it fixed.