After upgrading cmdstanr from 0.5.2 to 0.5.3, I getting “could not find include file” errors. I’m using cmdstan 2.30.1. Here’s a simple example:
Model file test.stan
data {
#include test_include.stan
int<lower=0> N;
vector[N] y;
}
parameters {
real mu;
real<lower=0> sigma;
}
model {
y ~ normal(mu, sigma);
}
Include file test_include.stan
int abc;
Output
> dir(pattern = "test.*.stan")
[1] "test_include.stan" "test.stan"
> cmdstan_model("test.stan", quiet = FALSE)
Compiling Stan program...
--- Translating Stan model to C++ code ---
bin/stanc --o=/home/karim/Code/rtemp/Rtmp2RffNR/model-3cc9c15d3306f.hpp /home/karim/Code/rtemp/Rtmp2RffNR/model-3cc9c15d3306f.stan
Syntax error in '/home/karim/Code/rtemp/Rtmp2RffNR/model-3cc9c15d3306f.stan', line 2, column 0, include error:
-------------------------------------------------
1: data {
2: #include test_include.stan
^
3:
4: int<lower=0> N;
-------------------------------------------------
Could not find include file test_include.stan in specified include paths.
Syntax error in '/home/karim/Code/rtemp/Rtmp2RffNR/model-3cc9c15d3306f.stan', line 2, column 0, include error:
-------------------------------------------------
1: data {
2: #include test_include.stan
^
3:
4: int<lower=0> N;
-------------------------------------------------
Could not find include file test_include.stan in specified include paths.
make: *** [make/program:50: /home/karim/Code/rtemp/Rtmp2RffNR/model-3cc9c15d3306f.hpp] Error 1
make: *** [make/program:50: /home/karim/Code/rtemp/Rtmp2RffNR/model-3cc9c15d3306f.hpp] Error 1
Error: An error occured during compilation! See the message above for more information.
I’ve been having the exact same issue with cmdstanr 0.5.3 and cmdstan 2.31.0 running on Manjaro Linux 6.1.12-1 (22.0.4. Sikaris).
Have you managed to find a solution to the issue?
I’ve tried prepending the file name with / to no luck. I’ve also checked and rechecked the file names and paths multiple times, but there doesn’t seem to be an issue (both files are in the same folder, and I don’t get an error for the main file, just the one included).
It seems like the above file was compiled in a temporary location, so possibly the included file isn’t being copied over? Does cmdstanr copy to temp locations to avoid things like spaces in paths?
Compiling Stan program...
Syntax error in '/tmp/RtmpwsQqiU/model-173245198317a.stan', line 2, column 4, include error:
-------------------------------------------------
1: generated quantities {
2: #include stan_include.stan
^
3:
4: a = normal_rng(0, 1);
-------------------------------------------------
Could not find include file stan_include.stan in specified include paths.
make: *** [make/program:50: /tmp/RtmpwsQqiU/model-173245198317a.hpp] Error 1
Error: An error occured during compilation! See the message above for more information.
I’m really not sure what could be the case. I’ve previously successfully used the functionality on the same OS (but more than six months ago); I’ve tried rerunning the old code, and got the same error message.
I believe this is resolved in the Github version of cmdstanr. Can you run remotes::install_github("stan-dev/cmdstanr"), then restart your session and try again?