Compile issue for RStan

Operating System: Windows 10 Enterprise
Interface Version: RStan Version: 2.18.1
Compiler/Toolkit: Sorry, I don't know what it means
Other potential helpful information list below:
R Version: 3.4.4
RStudio Version: 1.2.1335
RTools Version: 3.5  


I am a freshman for RStan, after install RStan as the specification from the website: , then I tried to run the Example 1 (8 schools) that mentioned in the link above.

However, the compile error message is showing as below:

fit <- stan(file = '8schools.stan', data = schools_dat)

Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created! file2638530d6dd0.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-34~1.4/etc/x64/Makeconf:215: file2638530d6dd0.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-34~1.4/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-34~1.4/share/make/" -f "//domain.internal/dfs/home/chzhang/My Documents/.R/" CXX='$(CXX11) $(CXX11STD)' CXXFLAGS='$(CXX11FLAGS)' CXXPICFLAGS='$(CXX11PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX11LDFLAGS)' SHLIB_LD='$(SHLIB_CXX11LD)' SHLIB="file2638530d6dd0.dll" WIN=64 TCLBIN=64 OBJECTS="file2638530d6dd0.o"' had status 2 
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-34~1.4/bin/x64/R CMD SHLIB file2638530d6dd0.cpp 2> file2638530d6dd0.cpp.err.txt' had status 1 
Error in sink(type = "output") : invalid connection

Additionally, two pieces of information might help for the solutions:

  1. I install the RStan in my company laptop;
  2. I strictly follow the installation specification from the link above to install the RStan and related things, there is no error message for installation.

Thanks for your input in advance!


[edit: escaped code]

Just for your convenience, I screenshot the code (first line) and related error message with the original format. Hopefully it might help. Thanks.

Can you provide your sessionInfo()? It doesn’t look like it’s finding StanHeaders, which also needs to be installed. It’s usually installed as a dependency of rstan, I believe.

Hi Bob,

Again, much appreciated for your quick input!

The screenshot below is what I get after run the statement - sessionInfo()


First try


Hi Ben,

Many thanks for your quick input, especially on Friday night!

It still does not work after remove and install.

However, two pieces of information may help:

  1. Since RStan is installed in my company laptop, the path is a little bit different from the traditional ones (start with “/*****”), as the screenshot below indicates, the path starts with “\****”:

  2. When I tried to re-install StanHeaders, RStan provide two options (Y/N) for “install from sources the package which needs compilation” as the screenshot below:

If I choose Yes, re-run the statement library(rstan), R provide the result as below:

Else if I choose No(Again, firstly remove/install StanHeaders), running library(rstan) is okay, and re-run the statement - fit <- stan(file = ‘8schools.stan’, data = schools_dat), different errors show as below:

It looks like you need to do


Hi Ben,

Thanks for your follow up.

I am off for couple days.

I installed the package of RcppEigen.
It has the same issue as the screenshot below indicates:

Something is messed up, but just try

install.packages("", repos = NULL)

Hi Ben,

Try the new link to install the RStan,but another error occurs:
The thing is I have install packages BH already.

It can’t find BH. Are you sure you have it for R 3.6?

Yeah, I the R and RStudio version information list below:

Hi Ben,

One thing might helpful:
After I installed BH, it does not show on the package list on the right bottom part of RStudio,as the screenshot below indicates.

What is

installed.packages()["BH", ]


What is your point? You mean you want me to install the BH package via the statemtent: installed.packages()[“BH”, ] ?

No. If you enter installed.packages()["BH", ], it will indicate if the BH package is already installed. Note that it reads “installed.packages”, not “install.packages”.

1 Like

Hi Ben,

Recently, I tried to another way to solve the issue:
RStan works well on my own laptop, and all related files: R, RStudio, RTools and related files are installed in C Drive.
Thus, I repeat the whole installation process in my company laptop. However, there is new error as the screenshot below:

Also, I run the sessionInfo(), screenshot for the information list below:

Could you please provide some solutions for the error message?

Just do

install.packages("", repos = NULL)

Hi Ben,

I tried to re-install RStan based on the link you provided. I don’t know why it always ask me to install ‘RcppEigen’, although I have installed. Please see the screenshot regarding the error and the new package installed based on the new link:


What is