I tried to compile the model in RStudio and got the below errors. I tried to use include_paths with no success: it just gives me a stanc error message about needing to “specify one model_file”.
> cmdstan_model("test.stan")
Compiling Stan program...
/
Syntax error in '/tmp/Rtmpcw36FD/model-34e0d7a3db5de.stan', line 2, column 0, include error:
-------------------------------------------------
1: functions {
2: #include test_functions.stan
^
3:
4: real foo() {
-------------------------------------------------
Could not find include file test_functions.stan in specified include paths.
make: *** [make/program:53: /tmp/Rtmpcw36FD/model-34e0d7a3db5de.hpp] Error 1
Error: An error occured during compilation! See the message above for more information.
> cmdstan_model("test.stan", include_paths = ".")
Compiling Stan program...
Please specify one model_file.
<snip>
If I use stanc on the commandline it is successful.
Now I tried to use the below with no success. I’ve seen a bunch of other forum discussions and some suggested some such solutions. Apologies if I missed the answer that would make my cmdstanr consistent with stanc. It seems that the include_paths should just work like the stanc one (as it is documented). I’ve previously used rstan and these include paths seem to work well.
Hey Karim, thanks for reporting this, that’s strange. I actually don’t get a stanc error when trying cmdstan_model("test.stan", include_paths = ".") with your Stan programs, so I’m not sure what’s happening here. I’m on Mac and not Linux but I don’t think this should be OS dependent (although I could be mistaken).
It’s weird no one else is getting this error. Here’s the full output of the error message, there’s a code at the bottom. I don’t know if it helps.
> cmdstan_model("test.stan", include_paths = ".")
Compiling Stan program...
Please specify one model_file.
Usage: stanc [option] ... <model_file.stan>
--debug-lex For debugging purposes: print the lexer actions
--debug-parse For debugging purposes: print the parser actions
--debug-ast For debugging purposes: print the undecorated AST, before semantic checking
--debug-decorated-ast For debugging purposes: print the decorated AST, after semantic checking
--debug-generate-data For debugging purposes: generate a mock dataset to run the model on
--debug-mir For debugging purposes: print the MIR as an S-expression.
--debug-mir-pretty For debugging purposes: pretty-print the MIR.
--debug-optimized-mir For debugging purposes: print the MIR after it's been optimized. Only has an effect when optimizations are turned on.
--debug-optimized-mir-pretty For debugging purposes: pretty print the MIR after it's been optimized. Only has an effect when optimizations are turned on.
--debug-transformed-mir For debugging purposes: print the MIR after the backend has transformed it.
--debug-transformed-mir-pretty For debugging purposes: pretty print the MIR after the backend has transformed it.
--dump-stan-math-signatures Dump out the list of supported type signatures for Stan Math backend.
--warn-uninitialized Emit warnings about uninitialized variables to stderr. Currently an experimental feature.
--warn-pedantic Emit warnings about common mistakes in Stan programs.
--auto-format Pretty prints the program to the console
--print-canonical Prints the canonicalized program to the console
--version Display stanc version number
--name Take a string to set the model name (default = "$model_filename_model")
--O Allow the compiler to apply all optimizations to the Stan code.
--o Take the path to an output file for generated C++ code (default = "$name.hpp")
--print-cpp If set, output the generated C++ Stan model class to stdout.
--allow-undefined Do not fail if a function is declared but not defined
--allow_undefined Deprecated. Same as --allow-undefined.
--include-paths Takes a comma-separated list of directories that may contain a file in an #include directive (default = "")
--include_paths Deprecated. Same as --include-paths.
--use-opencl If set, try to use matrix_cl signatures.
--standalone-functions If set, the generated C++ will be the standalone functions C++ code.
-help Display this list of options
--help Display this list of options
make: *** [make/program:53: /tmp/Rtmp5dvRrU/model-3ff0d7d430636.hpp] Error 127
Error: An error occured during compilation! See the message above for more information.
Both. The problem here is we automatically take the absolute path of “.” and supply that to cmdstan. And that absolute path has spaces in it in your case.
We need to fix that bug in cmdstanr. Will make an issue. In the meantime specify the path with ~/…
@rok_cesnovar FYI the spaces in paths issue is showing up in other functions too:
> xx <- read_cmdstan_csv(dist_fit_obj[[1]]$output_files())
grep: /media/karim/Code: No such file or directory
grep: Drive/karimn-code/takeup/data/stan_analysis_data/test_REDUCED_FORM_NO_RESTRICT-202012080958-1-8fb31c.csv: No such file or directory
Error: Supplied CSV file is corrupt!