I am using this github: https://github.com/CoryMcCartan/senate

Running on windows 10, rtools40, R 4.0.2

The error comes when the model is being recompiled

I’ve tried numerous troubleshoots online with no fix

The error I get is:

Compiling Stan program…

C:/Users/riley/AppData/Local/Temp/RtmpYDSJ9G/model-12e07704473d.hpp:3:10: fatal error: stan/model/model_header.hpp: No such file or directory

#include <stan/model/model_header.hpp>

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

mingw32-make.exe: *** [make/program:61: C:/Users/riley/AppData/Local/Temp/RtmpYDSJ9G/model-12e07704473d.exe] Error 1

Error: An error occured during compilation! See the message above for more information.

Hi Riley,

Just to clarify, the error only happens when the model is being re-compiled, there’s no error when compiling the first time?

It compiles other models in the program. It will throw the error when compiling this stan model for the first time.

Can you post the code you use to prepare the data and run the model?

polls_model_path = file.path(opt$model_dir, “polls”)

…

model_d = compose_data(polls_d, .n_name = n_prefix(“N”),

N_race = nrow(race_prior_d2020),

D = n_days,

W = n_weeks,

D_W = ceiling(n_days/n_weeks),

week_frac,

week_day = floor(wnum) + 1,

prior_natl_mean = mean(natl_prior_pred),

prior_natl_sd = sd(natl_prior_pred),

prior_race_mean = race_prior_mean,

prior_race_cov = race_prior_cov,

prior_rv_bias = 0.011,

prior_lv_bias = 0.0,

prior_a_bias = 0.02,

lv_rv_ratio = 8,

poll_errors,

)

#this is the line that causes the error

polls_model = get_polls_m(polls_model_path, opt$recompile)

What happens if you run:

```
polls_model = cmdstan_model("stan/polls.stan")
```

instead?

That worked perfectly, thank you so much!

Mind if I ask what’s the difference?

I’m not entirely sure, but as a guess, could you try running:

```
polls_model = cmdstan_model("stan/polls.stan", cpp_options=list(CXXFLAGS="-Ofast"))
```

And see if you get the same error as before?

That works without error as well

What about:

```
polls_model = get_polls_m(polls_model_path, recompile = TRUE)
```

also working

I’m not too sure what the issue was… hm

That is an odd one. Do you still get the error with:

```
polls_model = get_polls_m(polls_model_path, opt$recompile)
```

If so, I wonder if it’s the `opt`

list, maybe try:

```
opt$recompile = TRUE
polls_model = get_polls_m(polls_model_path, opt$recompile)
```