Cmdstanr compilation error with no detailed message

Hi,all
I was trying to compile my model but an error occurs without any information or log.
I can’t even see what wents wrong.

mod <- cmdstan_model("binomial.stan")
Compiling Stan program...
Error: An error occured during compilation! See the message above for more information.

I tried an example:

> file <- file.path(cmdstan_path(), "examples", "bernoulli", "bernoulli.stan")
> mod <- cmdstan_model(file)
Model executable is up to date!
> class(mod)
[1] "CmdStanModel" "R6" 

which seems working.
But another example:

stan_program <- write_stan_file("
 parameters {
   real x;
 }
 model {
   real mu = -2;
   x ~ normal(fabs(mu), 1);
 }
 "
 )
> mod <- cmdstan_model(stan_program)
Compiling Stan program...
Error: An error occured during compilation! See the message above for more information.

Again, there’s just a notice of error but nothing detailed about it.

Any ideas how can I solve this problem?

Can you try with quiet =FALSE argument and post the output?

This seems weird that its not popping up which makes me think the error occurs after the Stan to C++ conversion.

1 Like

I just had the same issue and using quiet = FALSE the model compiles, otherwise it doesn’t.

This is on Windows 10.

1 Like

It compiles with quiet=FALSE and doesnt compile quiet=TRUE? That is weird.

Can you share the model?

1 Like

Now I cannot recreate :/

I’ll keep an eye out and see if this happens again. I’ll post if I can get it to happen consistently

2 Likes

Everyone, Thanks for replying!
Here’s what I got:

stan_program <- write_stan_file("
 parameters {
   real x;
 }
 model {
   real mu = -2;
   x ~ normal(fabs(mu), 1);
 }
 "
 )
> mod <- cmdstan_model(stan_program, quiet = FALSE)
Compiling Stan program...
mingw32-make.exe: *** No rule to make target 'C:/Users/Mike Xu/AppData/Local/Temp/RtmpYHKjEF/model-14389ce321.exe'.  Stop.
Error: An error occured during compilation! See the message above for more information.

So a error pops up. I searched on google but didn’t come up with a solution…

are you using windows and connecting to a remote server?

I found out that I had the stan file saved on a remote server and it wouldn’t let me compile the model unless I had it locally.

2 Likes

Hm, thats interesting. Not sure why that would cause a problem. It shouldnt for cmdstan itself, but might be an R or path issue. I am guessing the path to the models is something like \\DRIVE\....

This is just a regular network drive you have mapped in Windows?

1 Like

yes, exactly

2 Likes

No…
I’m using windows but not remotely.

Ah, I think I can see the issue now.

The space in “C:/Users/Mike Xu” is causing the issue, thats where your R temp folder is located at the moment. Will check whats the easiest way to fix this.

1 Like

I finally solved it. There can’t be any space in the address of R temp folder, which in my case the space between “Mike” and “Xu”.
First I tried to change my user folder name and it turns out to be complicated.
In the end, I just simply changed all temp path to another folder and solved the problem.

Again, thank you all for replying and helping! @rok_cesnovar @spinkney

1 Like

Hi,

thanks for the report and glad you fixed it. Can you point to a guide you used or explain a bit more what exactly you mean by “ I just simply changed all temp path to another folder”.

Thanks!

Oh, I mean I changed the “TEMP” and “TMP” in advanced system setting-> environment variables-> user variable.

1 Like